Page is a not externally linkable
jdMorgan - 6:35 pm on Sep 22, 2006 (gmt 0)
Your ErrorDocument directives are malformed, and will lead to a 302-Moved Temporarily response for any of those errors. See the notes in the ErrorDocument documentation [httpd.apache.org] for details on this. To return the correct response code for each error, use: miki, It also removes the end-anchor from the domain name test, so it won't break if a port number is appended, and removes the unneeded anchoring on the ".*" RewriteRule pattern. Jim [edited by: jdMorgan at 6:48 pm (utc) on Sep. 22, 2006]
trader,
ErrorDocument 404 /index.html
ErrorDocument 401 /index.html
ErrorDocument 402 /index.html
ErrorDocument 400 /index.html
I also strongly suggest that each of these errors be directed to a page that describes the specific error, which in turn provides a text link to your index page and/or site map to aid the visitor. You may also add a 5-to-10-second meta-refresh on those error pages to send the browser to your home page or site map if you so desire.
To avoid a double redirect on client index.html requests, I'd suggest:
RewriteEngine on
RewriteBase /
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.html\ HTTP/
RewriteRule index\.html$ http://www.example.com/%1 [R=301,L]
#
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
This reverses your rules, so that the more specific case of a request for /index.html is taken care of first, regardless of whether the canonical domain is requested.