#1
  1. No Profile Picture
    Php Slave
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Posts
    463
    Rep Power
    13

    Help needed with rewrite rule


    Hi,

    I have made a rewrite rule that do the following:

    www.domain.com/filename -> www.domain.com/filename.php

    That works fine. However, when i put a trailer on the end then i receive an internal error. Example:
    www.domain.com/filename/

    How can i make it so that it works with a trailer, for example:

    www.domain.com/filename/ -> www.domain.com/filename.php

    My current rewrite rule:
    PHP Code:
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond 
    %{REQUEST_FILENAME}\.php -f
    RewriteRule 
    ^(.*)$ $1.php 
    Thanks in advance!
    Last edited by JasonL; November 5th, 2012 at 09:15 AM.
    There are no mistakes in life....only lessons!
  2. #2
  3. mod_dev_shed
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    14,817
    Rep Power
    1099
    You should first decide what a page's URL should be. Do you want it to have trailing slashes or not? If not, make sure you're only linking to /foo and never /foo/, then force your standard (above your other rules):
    Code:
    RewriteRule ^(.+)/$ /$1 [R=301,L]
    # Jeremy

    Explain your problem instead of asking how to do what you decided was the solution.

IMN logo majestic logo threadwatch logo seochat tools logo