Forum Moderators: phranque
for example
www.domain.com//page.htm
www.domain.com//directory/newpage.htm
they all return a url. I believe the best solution is to return a 404 and was wondering the best way to write this to over all possible occasions of a //
thanks for any help!
# Fix extra leading slashes in URL
RewriteCond %{REQUEST_URI} ^//+(.*)
RewriteRule .* /%1 [R=301,L]
Jim
That's true, and the code is documented as behaving in that way...
# Fix extra leading slashes in URL
Really only a small tweak is needed to modify it:
# Fix double slashes in URL
RewriteCond %{REQUEST_URI} ^(.*)//+(.*)
RewriteRule .* /%1/$2 [R=301,L]
For already-indexed URLs, a 301 is the correct response.
Jim
Remember that Google indexes/lists/analyzes URLs, not pages. In fact, dynamic sites don't have 'pages' at all -- everything is generated on-the-fly by one script or a few scripts.
If they find a URL, then that URL exists, plain and simple. Therefore, the 301 is used to say, "The content you want is now located at this (new/different) URL. Please re-request it from that URL." This tells the search engines to throw away or ignore the current URL and use the one you provide with the 301 response.
A 404 is generally an indicator of a poor-quality site, while a 301 --if there are not too many of them and they are not used to make up for too many URLs that change too frequently-- indicates that "someone cares for this site enough to ask us to correct this URL."
If you feel you must reject these double-slash requests, then use a 410-Gone response. This tells the search engines unequivocally that the resource associated with the requested URL has been removed and will not come back.
But both 404 and 410 say the resource is not available, and if a customized error document is not used to provide aome help in finding what was requested, that the Webmaster can't be bothered to help visitors who request that URL...
Jim