Apache's mysterious trailing slash

You may find that some sites do not work well if you omit a trailing slash on the URL. For example, if you have a directory on domain.com called "news", the following two URL's should take you to the same place:

http://domain.com/news

http://domain.com/news/

If you find that they do not take you to the same place, be sure that the mod_dir (Apache 1 or Apache 2) module is being loaded in Apache. If that module is being loaded, and you're still having problems, make sure mod_rewrite is loaded as well.

If none of that works, make sure that there is no ErrorDocument 301 or ErrorDocument 302. Should either of those exist, promptly slap the developer/sysadmin that enabled those options. Apache will do a 301 redirect when the trailing slash is missing so that the user will be directed to the correct location, and if there is an ErrorDocument 301, this error document will always be presented rather than the proper redirection to the directory on your site.

Printed from: http://rackerhacker.com/2007/03/23/apaches-mysterious-trailing-slash/ .
© Major Hayden 2012.

Leave a Reply

 

  • Welcome! I started this blog as a way to give back to all of the other system administrators who have taught me something in the past. Writing these posts brings me a lot of enjoyment and I hope you find the information useful. If you spot something that's incorrect or confusing, please write a comment and let me know. Drop me a line if there's something you want to know more about and I'll do my best to write a post on the topic.
    -- Major Hayden

    Flattr this