Remove Trailing Slashes, Force Index


/ Published in: Apache
Save to your folder(s)

Removes trailing slashes from URLs, forces all urls to index.php


Copy this code and paste it in your HTML
  1. RewriteCond %{http_host} ^MyExample.com [nc]
  2. RewriteRule ^(.*)$ http://www.MyExample.com/$1 [r=301,nc,L]
  3.  
  4. RewriteBase /
  5.  
  6. RewriteCond %{REQUEST_FILENAME} !-d
  7. RewriteRule ^(.+)/$ /$1 [R=301,L]
  8.  
  9. RewriteCond %{REQUEST_FILENAME} !-f
  10. RewriteCond %{REQUEST_FILENAME} !-d
  11. RewriteRule . /index.php [L]

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.