Page 1 of 1

apache/htaccess: how to avoid redirecting dir to dir/

Posted: Fri Nov 27, 2009 9:27 am
by Apollo
Suppose I have a subdir foo/ on my website.
If I go to http://www.example.com/foo Apache will automatically redirect me (by giving me a 301 Moved Permanently) to http://www.example.com/foo/ (with the slash) and get whatever is inside the foo/ dir (if anything and visible, or an error otherwise).

Now, is there also some .htaccess option or smart rewrite rule that will avoid this?
Well, i could do RewriteRule ^foo$ bar of course, but I mean in general, i.e. for any subdir?

(btw I don't really need this in a practical situation, but stumbled upon this while struggling with another problem, and just wondering)

Re: apache/htaccess: how to avoid redirecting dir to dir/

Posted: Fri Nov 27, 2009 3:41 pm
by requinix
DirectorySlash is what you're looking for, but I'd advise against it unless someone really knows what they're doing.

Re: apache/htaccess: how to avoid redirecting dir to dir/

Posted: Sun Nov 29, 2009 5:12 am
by Apollo
Thanks tasairis, that's it!