Forum Moderators: phranque
I discovered the case sensitivity problem straight away, and I've been looking for a clear solution to either have any emails sent to the above addresses sent to the right folder, regardless of case, or using mod_spelling, but I can't get anything to work.
This is what I have tried:
CheckSpelling On
RewriteEngine On
RewriteRule ^fsbo/index\.html ^FSBO/index.html [NC]
What am I doing wrong? I would really appreciate any help.
Thanks, Matt
[edited by: jdMorgan at 1:43 pm (utc) on Jan. 21, 2008]
[edit reason] example.com [/edit]
Also, consider whether you want to use an internal rewrite, or an external 301-Moved Permanently redirect; Using an internal rewrite leaves all case variations of these URLs to be index by search engines, creating a duplicate-content problem which may impair their search ranking.
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim
If that does not solve your problem, you can indeed use mod_rewrite (and remove CheckSpelling On), but rewriting "something" to the "same something" makes no sense, this can cause an infinite loop.
Then; if you have a directory called FSBO, and you type fsbo in the address bar of he browser (but not the index.html), then Apache will not find that resource, because your RewriteRule rewrites only request for FSBO/index.html, but since Apache does not find the directory, it will never reach your RewriteRule.
Also note that in the replacement string of RewriteRule, you don't need to use regular expressions anymore, so the starting anchor (^) is not needed anymore, if you leave it there, it will become the part of the rewritten url.
To make your mod_rewrite directives effective, you'll need something like this:
#
# This is needed to make the internal rewriting possible
# in .htaccess files
Options +FollowSymLinks
RewriteEngine On
#
# Tell mod_rewrite that we're in the root directory
# (probably would work without this too - depends on the server config)
RewriteBase /
#
# If the requested resource is the anything from the /FSBO
# directory (with all capitals), do not process the next RewriteRule.
# Note the exclamation mark.
RewriteCond %{REQUEST_URI}
!^/FSBO(/.*)?$
#
# Rewrite anything from the fsbo directory regardless of its case
# to the FSBO directory, but only if the above RewriteCond did not match.
RewriteRule ^fsbo(/(.*))?$ /FSBO/$2 [NC,L]
Remember that it is the client (browser or robot) that resolves relative links. It does so by using the lowest-level directory path present in the page URL currently showing in its address bar. Therefore, the behaviour you see is expected.There are several choices to avoid problems with link resolution:
Use server-relative links, instead of page-relative links -- e.g. <img scr="/logo.gif> Use canonical links: <img src="http://example.com/logo.gif"> Rewrite requests for included objects back to the correct path (rewrite page-included objects only, not the pages themselves) Jim
See [webmasterworld.com...]