301 redirect on "www" domain not working...help please!!

New to mod_rewrite? This is a good place to start.

301 redirect on "www" domain not working...help please!!

Postby memerson » Tue May 18, 2010 6:46 am

Hello everyone,

I'm kind of a noob when it comes to htaccess and mod_rewrite, so anyone who can point me in the right direction will be very much appreciated.

I have recently changed a site address and I need the old address to redirect to the new. I have no problem with that. However, some of the directory structures on the old site are completely different (the new site uses Wordpress) and I need everything from the old site that DOESN'T EXIST on the new site to go straight to the new site's front page.

So far I have:

Code: Select all
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^old-domain\.com/$
RewriteRule (.*) http://new-domain.co.uk/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.ld-domain\.com/$
RewriteRule (.*) http://new-domain.co.uk/$1 [R=301,L]

redirect 301 / http://new-domain.co.uk


WHich will work on anything except any file that begins with "www.". However the old domain written in directly (http://www.old-domain.com) will redirect but http://www.old-domain.com/somedirectory/somefile.asp WON'T, even though http://old-domain.com/somedirectory/somefile.asp WILL.

Any one have any ideas?

Thank you in advance
Michael
memerson
 
Posts: 11
Joined: Tue Apr 17, 2007 6:04 am

Return to Beginner's Corner

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

cron