I want to do something which i think should be quite simple.
I have built a new website which uses mod rewrite for its simple urls.
home.html -> index.php?page=home
blah.html -> index.php?page=blah
All urls are in this format. So i use:
Code: Select all
RewriteEngine on
RewriteRule ^(.*)\.html$ index.php?page=$1 [L]
ErrorDocument 404 /index.php?page=error
Now the complex bit: the old site - it had some weird and horrible urls. Some has been indexed by google, and some are linked to. We dont want to loose this traffic, so it needs to be redirected to the homepage.
What i now need is that anything that isnt the homepage:
/
or the new urls:
/blah.html
to be 301 redirected to:
/
I have been fiddling with something like this:
Code: Select all
RewriteEngine on
RewriteRule ^(.*)\.html$ index.php?page=$1 [L]
RewriteCond %{REMOTE_ADDR} !^(\.html)$ [NC]
RewriteRule .* / [L,R=301]
ErrorDocument 404 /index.php?page=error
Pls can anyone put me out of my misery so i can get some sleep