You are here:  » htaccess 'catch all' rule for migrated site


htaccess 'catch all' rule for migrated site

Submitted by ChrisNBC on Tue, 2014-07-15 11:23 in

Hi David,

Hope all is going well.

I wondered if you might be able to offer some advice on htaccess rewrite rules...

In summary, I'm updating an old site. The updates have pretty much gone to plan except for one thing. Google have indexed a large number of URL's from the old site. The site is niche so I have created 1 to 1 rules to redirect all the main pages but I would like to include a 'catch all' rule in the htaccess file which will redirect all search traffic (not matched by 1 to 1 rules. So for example:

www.mysite.co.uk/pt/filename1.php

would become:

www.mysite.co.uk/filename1.php

The htaccess file I have created sits in the /pt/ folder as this was the root of the old install.

I wondered if you could suggest what the rule should be?

Thanks in advance.

Regards
Chris

Submitted by support on Tue, 2014-07-15 11:33

Hi Chris,

It should be just:

RewriteRule ^(.*) http://www.mysite.com/$1 [L,R=301]

The fully qualified URL is necessary in the rewrite location to override RewriteBase in the .htaccess file.

Cheers,
David.
--
PriceTapestry.com

Submitted by ChrisNBC on Tue, 2014-07-15 14:23

HI David,

Thanks as always for your super quick response. That sorted the redirect perfectly and all the residual traffic is now being caught.

Best regards
Chris