Entry
How do I make a URL not require a trailing "/"? Example: http://www/testdir, instead of http://www/testdir/
Aug 21st, 2001 14:27
Bruce Christensen, Scott Campbell, http://www.engelschall.com/pw/apache/rewriteguide/#ToC7
The short answer is to add the following to your httpd.conf file:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [R]
Then make sure that you're loading mod_rewrite (or that it's compiled
into Apache).
This basically says that when:
1. The requested file is a directory, and
2. the URL doesn't end in a slash
to add a slash. This causes an external redirect (using the Location
HTTP header).