Describe:
Each net owner has been tortured by a trailing slash problem, and if there is no trailing slash in the URL, the server will assume that the URL is invalid and return an error because the server will look for the file Foo based on/~quux/foo instead of displaying the directory. In fact, many times, this problem should be left to the user to add "/" to solve, but users will directly enter the Web site. This will result in a 301 redirect request. And then again looking into the/index.html.
Method:
The most intuitive way is to make Apache automatically plus "/", the use of external redirection to the browser can correctly find the file, if we only do internal redirection, you can only display the table of Contents page, in this directory page image file will be due to the relative URL of the problem can not find. For example, when we request a/~quux/foo/index.html image.gif, redirects become/~quux/image.gif.
So we should use the following methods:
Rewriteengine on
Rewritebase/~quux/
Rewriterule ^foo$ foo/[R]
This method also applies to. htaccess files are set within each directory, but this setting overrides the original primary configuration file.
Rewriteengine on
Rewritebase/~quux/
Rewritecond%{request_filename}-D
Rewriterule ^ (. +[^/]) ___fckpd___17nbsp; $1/[R]