Forum Moderators: phranque
[edited by: bill at 12:50 am (utc) on Jul 13, 2015]
[edit reason] Use example.com [/edit]
[edited by: bill at 12:53 am (utc) on Jul 13, 2015]
[edit reason] Use example.com [/edit]
[edited by: bill at 12:52 am (utc) on Jul 13, 2015]
[edit reason] Use example.com [/edit]
RewriteEngine OnThese two lines have nothing to do with each other. RewriteEngine On is a directive to switch on mod_rewrite. Redirect by that name is a mod_alias directive. You should never, ever use both. (That is: redirect with both. mod_alias has other uses too, but those are mainly in the config file.) So convert all your mod_alias redirects to use mod_rewrite.
Redirect 301 ...
[edited by: bill at 8:55 am (utc) on Jul 15, 2015]
[edit reason] Use example.com [/edit]
DirectoryIndex index.php3 index.php pictures.pl index.html default
THIS SHOUL BE THE REDIRECT 404 errors TO NEW PAGE. IS THIS CORRECT.
ErrorDocument 404 /missing.html
ErrorDocument 404 /boilerplate/my404.html
et cetera. Your choice; this can be changed at any time. Redirect 301
RewriteRule ^(([^/]+/)*)index\.html http://www.example.com/$1 [R=301,L,NS]
OR RewriteCond %{THE_REQUEST} ^[A-Z]+ /(([^/]+/)*)index\.html
RewriteRule index\.html http://www.example.com/%1 [R=301,L,NS]
There are some other variations. Notably: if your URL paths never, ever include . periods, then you can express the ([^/]+/)* part as [^.]+ instead. There are some other variations, having more to do with coding style than anything else. RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-dNow, wait. This is the first I've heard of extensionless URLs. You should bend over backward to avoid -d and -f tests, because they're a lot of extra work for the server. If you really do have a mix of extensionless and html URLs, which is what this rule is for, we can hammer out the optimal form of the rule.
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
the "missing.html" i should replace this by my old page html?
ErrorDocument 410 /missing.html
again replacing "missing.html" with the actual path-and-name of your 404 document. Yes, it can be the same physical page. You probably don't have any 410s right now, but this way you don't have to worry about it. The Apache default 410 message is even scarier and less user-friendly than the default 404 message.