Forum Moderators: Robert Charlton & goodroi
it occasionally does things like 301 to a 404 because of it
RewriteRule ^(missing|forbidden)\.html - [L]
listing all your error documents by name, with the appropriate path. (I once forgot this line on a test site, and was baffled at the number of malign agents requesting the 403 page by name. Oops. Some of them still come back periodically and ask for it.) Hostname then doesn't matter, because the request will never go any further. The non-www to www should be after all other rewrite rules:
Too many redirects is leading to redirect chains.
I'm considering returning 404 for any and all URLs that are not wanted.
code to redirect any uri containing index.php
code to redirect any url missing the www
code to remove any url ending in .html
code to 404 all valid URLs where numbers are attached, ie: example.com/legit-page/1231231 should be example.com/legit-page
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule ^(real-name|other-real-name|third-real-name) http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteCond %{REQUEST_URI} ^(.+)
RewriteRule \.(css|js|png|gif|jpg) http://www.example.com/%1 [R=301,L]
But how often do people request images by the wrong hostname? Do search engines make a habit of it? but 410 makes the googlebot go away faster.