Remove Trailing Slash htaccess

Discussion in 'Site & Server Administration' started by Aids, Dec 10, 2010.

  1. #1
    Can anyone provide me with a code to rewrite all URLs with a trailing slash and replace them with the URL without the slash?

    Thanks,
    Mark
     
    Aids, Dec 10, 2010 IP
  2. Mia

    Mia R.I.P. STEVE JOBS

    Messages:
    23,694
    Likes Received:
    1,167
    Best Answers:
    0
    Trophy Points:
    440
    #2
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteCond %{REQUEST_URI} !/$
    RewriteRule (.*) $1\.php [L]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)/$ /$1 [R=301,L]
     
    Mia, Dec 10, 2010 IP
  3. Aids

    Aids Peon

    Messages:
    195
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks a lot! It worked :D

     
    Aids, Dec 10, 2010 IP
  4. Mia

    Mia R.I.P. STEVE JOBS

    Messages:
    23,694
    Likes Received:
    1,167
    Best Answers:
    0
    Trophy Points:
    440
    #4
    No problem. Glad to be of help.
     
    Mia, Dec 10, 2010 IP