Friday, June 24, 2016

Apache Rules - I

Apache Trailing Slash Implementation


# first rule removes ending in files (eg : not like /abc.html .. this will now include urls with and without trailing slash)
# second rule removes urls ending in trailing slash
# therefore rewrite rule will match ONLY normal non-file urls not ending in trailing slash

       RewriteCond %{REQUEST_URI} /+[^\.]+$
       RewriteCond %{REQUEST_URI} ^(.*(?!/).)$
       RewriteRule ^(.*)$ $1/ [QSA,R=301,L]