Understanding the Trailing Slash Problem


Understanding the "Trailing Slash" Problem

DirectorySlash On


Sometimes, certain URLs only work only if they have a "/" at the end. This is likely because you have either not loaded mod_dir into the server or because the redirections made by mod_dir are not working correctly with the value specified in the ServerName directive, as explained in the "Redirections Do Not Work" section in Chapter 2.

When accessing certain URLs that map into directories, it is necessary to add a trailing slash ("/") to the end of the URL to correctly access the content of the directory, which can be either an index file or a directory index. Forgetting to add this trailing slash is a common mistake, so when mod_dir realizes that may be happening, it issues the appropriate redirection.

For example, if mod_dir is enabled on the server, and you have a directory named foo under the document root, a request for http://example.com/foo will be redirected to http://example.com/foo/.

This is the default behavior in both Apache 1.3 and 2.0 when mod_dir is loaded into the server. In Apache 2, you can disable such redirections using a DirectorySlash directive:

DirectorySlash Off





Apache(c) Phrase Book(c) Essential Code and Commands
Apache Phrasebook
ISBN: 0672328364
EAN: 2147483647
Year: 2006
Pages: 254

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net