Need to set up redirects for multiple pages in .htaccess...how?

Hi,

I have been using cpanel to set up 301 redirects of pages to be redirected to another site but am not having much success. I have been told i need to do this with mod rewrite which is fine but i don’t get it…I have looked at some tutorials but would like an example of my actual situation so i can apply this to the other pages.

For instance how will I redirect this:
http://www.MyWebsiteOld.co.uk/About.php

To
http://www.MyWebsite.co.uk

In the .htaccess file the code has been generated as follows:

RewriteCond %{HTTP_HOST} ^ MyWebsiteOld.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www. MyWebsiteOld.co.uk$
RewriteRule ^About\.php$ “http\:\/\/www\. MyWebsite.co\.uk” [R=301,L]

…but it doesn’t appear to be redirecting the page.

The main index.php file redirects so when i go to www.MyWebsiteOld.co.uk i get redirected to www.MyWebsite.co.uk but no other pages do.

Can anyone help?

Thanks

G

I have something like this that works for me.


RewriteEngine On

RewriteCond %{HTTP_HOST} ^MyWebsiteOld.co.uk [NC]
RewriteCond %{HTTP_HOST} ^www.MyWebsiteOld.co.uk [NC]
RewriteRule ^(.*)$ http://www.MyWebsiteOld.co.uk/$1 [L,R=301]

Hope this helps.

First question - do you want www.mywebsiteold.co.uk/about.php to be redirected to
www.mywebsite.co.uk, or
www.mywebsite.co.uk/about.php?

If it’s the first one, mapping all your pages from the old site onto just the home page is going to be very unhelpful for people using your site.

thanks for the replies.

You’re right Stevie that would be unhelpful so it’s probably better if i redirect to a page of similar/same content.

Using CS-Bills example would i do the following:

RewriteCond %{HTTP_HOST} ^MyWebsiteOld.co.uk [NC]
RewriteCond %{HTTP_HOST} ^www.MyWebsiteOld.co.uk/About.php [NC]
RewriteRule ^(.*)$ http://www.MyWebsiteOld.co.uk/About.php$1 [L,R=301]

??

still trying to get this to work…

RewriteCond %{HTTP_HOST} ^MyWebsiteOld.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www.MyWebsiteOld.co.uk$
RewriteRule ^About\.php$ “http\:\/\/www\.MyWebsite\.co\.uk\/About\.php” [L,R=301]

The above doesn’t work but seems to follow the conventions i’ve read about.

anyone any ideas why it’s not working?

I recommend you contact your web host and ask them to install redirect on the server side.