Forum Moderators: phranque
How would I use mod_rewrite to redirect close-but-no-cigar hits to my home page...
http:// www.example.com./
http:// www.example.com.
(note the dot-slashes; the dots after the .com)
...to this...
http:// www.example.com/
I tried the following and proceeded to lock absolutely everybody out (oops):
SetEnvIfNoCase Referer "./" keep_out
So I thought I'd better touch base here, before making another mess of things m'self. Would what I'm hoping to do be akin to...
RewriteRule ^\./$ http:// www.example.com/welcome.html [R,L]
(or)
RewriteRule ^\.com./$ http:// www.example.com/welcome.html [R,L]
(or)
...?
Thanks in advance for your help!
2.) BACKSTORY:
In the old days, dot-slashers were usually up to no good, trying to crawl directories and snoop around. In recent years, dot-slash errors usually pointed back to a misconfigured robot.
But now, these visitors appear to be regular folks unwittingly making a mess of my error logs, and when they bookmark the bad beginning URL, they keep making messes.
They're arriving A-OK, but the first thing they see is a customized error page because their browsers are looking for a page (./) that doesn't exist.
They're also generating errors they don't see because the dot-slash means the following 'domain' as a referer becomes a not-okay hot-linker:
http:// www.example.com./graphic.jpg
Alas, there doesn't appear to be a common incoming link or else I could at least rewrite that (or ask the site with the wonky link to fix it).
I'd try:
# Handle www.example.co[b]m/.[/b] variants
RewriteRule ^\. http://www.example.com/ [R=301,L]
#
# Handle www.example.co[b]m./[/b] variants
RewriteCond %{HTTP_HOST} ^www\.example\.com\.
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
A dot at the end of the hostname is part of the domain name, not part of the URL, so RewriteRule can't "see it" and you have to use RewriteCond %{HTTP_HOST}
A dot after the domain-name/ is part of the URL, so that was just an anchoring and pattern issue.
Jim