Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy .htaccess rewrite

    please help me here,i need immediate response
    I like to rewrite this url:
    www.hamroworld.com/anyvariable
    to http://www.hamroworld.com/profile.ph...le=anyvariable

    The anyvariable can be anything not only anyvariable.

    For eg:if someone enters hamroworld.com/username ,she/he should get the content of hamroworld.com/profile.php?profile=username.

  • #2
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    To do this just put this into your .htaccess file:

    Code:
    RewriteEngine on
    RewriteRule ^([a-zA-Z0-9-_]+)$ /index.php?profile=$1
    This will allow:
    www.hamroworld.com/anyvariable = www.hamroworld.com/profile.php?profile=anyvariable
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •