RewriteRule, removing the end of the url?

Discussion in 'Apache' started by mahmood, Aug 30, 2007.

  1. #1
    Hey

    I need to remove the ".php" part of some urls, how do I do that? for example I want myPage.php converted to myPage.
     
    mahmood, Aug 30, 2007 IP
  2. cyanide

    cyanide Peon

    Messages:
    483
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I'm not sure if there is a way to do that in htaccess.
    But you could just create a folder called myPage, put your page in there and rename it index.php, then link to it like /myPage/
     
    cyanide, Aug 30, 2007 IP
  3. just-4-teens

    just-4-teens Peon

    Messages:
    3,967
    Likes Received:
    168
    Best Answers:
    0
    Trophy Points:
    0
  4. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #4
    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)$ $1.php [L]

    But if you use any other script, those won't work. And images will probably be messed up. Adding a / to the URL would probably fix that, unless you have folders.

    RewriteRule ^([^.]+)/$ $1.php [L]
     
    Nintendo, Aug 31, 2007 IP