Simple .htaccess help

Discussion in 'Site & Server Administration' started by ourktm, Jul 29, 2009.

  1. #1
    Hi,

    I have a simple .htaccess question.

    I want to 301 redirect this way

    mysite.com/profile.php?user=username to mysite.com/username/
     
    ourktm, Jul 29, 2009 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    use this

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*)/$ /profile.php?user=$1
    Code (markup):
     
    Bohra, Jul 30, 2009 IP
  3. ourktm

    ourktm Active Member

    Messages:
    2,148
    Likes Received:
    55
    Best Answers:
    0
    Trophy Points:
    90
    #3
    When I do that nothing happens. When I go to my old page mysite.com/profile.php?user=username i want the page to be automatically redirected to the new page mysite.com/username/
     
    ourktm, Jul 30, 2009 IP
  4. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #4
    .htaccess wont redirect u have to modify ur php code to do that
     
    Bohra, Jul 30, 2009 IP
  5. ourktm

    ourktm Active Member

    Messages:
    2,148
    Likes Received:
    55
    Best Answers:
    0
    Trophy Points:
    90
    #5
    What about those 301 redirects? Won't they work too?
     
    ourktm, Jul 31, 2009 IP
  6. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #6
    They will just redirect the same as this but to change the urls in the script u have to modify the code
     
    Bohra, Jul 31, 2009 IP