Mod-write htaccess help

Discussion in 'Apache' started by red-x, Mar 6, 2009.

  1. #1
    Hi guys I'm trying to mod-write some urls in my website but is not working.
    I want to change this url..

    www.website.com/?pg=register to www.website.com/register/

    I have this htaccess code..
    RewriteRule ^(.*)/$ ?pg=$1 [QSA,L]
    Code (markup):
    it works but when I try to go to a directory like website.com/forums I get a 404 error page.

    I have been using..
    RewriteRule ^register/*$ ?pg=register [L]
    Code (markup):
    But I need a code that works with all urls not just one.

    Thank you in advance for any help :)
     
    red-x, Mar 6, 2009 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    You have to include the file name in it, probably index.php

    Apache won't know if it's wacko.php or index.html or jh67-64ihY76hsyd.php

    RewriteRule ^(.*)/$ index.php?pg=$1 [L]
     
    Nintendo, Mar 6, 2009 IP
  3. buldozerceto

    buldozerceto Active Member

    Messages:
    1,137
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    88
    #3
    if you need only for that url
    RewriteRule ^/?register/$ index.php?pg=register
     
    buldozerceto, Mar 7, 2009 IP
  4. kipper777

    kipper777 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I need to change this link:
    http://www.expressnightout.com/content/2011/08/beyond_wagon_wheels_and_calico_country_c.php.
    to
    http://www.expressnightout.com/2011/08/beyond_wagon_wheels_and_calico_country_c/

    Form the old site, there are many backlinks out there that I simply cannot change, so I need to write a rule to remove the /content/ AND take the .php off

    If you could help me write and/ or show me a good resource so I can figure this out myself. That would be great. Thanks
     
    kipper777, Sep 26, 2011 IP