Saturday, March 1, 2008

.htaccess fix for trailing slash(es) on server-parsed HTML files

I now have a complete fix for not only trailing slash(es), but also characters following the slash, and a redirect to the proper/permissible path.

RewriteEngine on
RewriteCond %{REQUEST_URI} ^(.*\.shtml?)/.*
$RewriteRule ^.*$ http://%{HTTP_HOST}%1 [R=301,L]

You also deny these altogether by changing [R=301,L] to [F,L]. This will generate a 403 FORBIDDEN response.