Abram
Abram

Reputation: 41914

Redirecting a domain with htaccess with a few specific 301s

Is it possible to do something like this to redirect old traffic to the new site with a 301.

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !new-example.com$ [NC]
RewriteRule ^(.*)$ http://new-example.com/$1 [L,R=301]

However, I will need to manually map some pages to their new equivalent pages like

Redirect 301 /about http://new-example.com/about-us

Is it possible to do both?

Upvotes: 0

Views: 23

Answers (1)

Panama Jack
Panama Jack

Reputation: 24468

If you are going to use Rewrite, then use it only. I don't recommend use both mod-alias and mod-rewrite. You can use rewrite to map to individual pages too. Also the order matters. The catchall rule should be the last one. This would provide cleaner code IMO.

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^new-example.com$ [NC]
RewriteRule ^about/?$ http://new-example.com/about-us [R=301,L]

RewriteCond %{HTTP_HOST} !new-example.com$ [NC]
RewriteRule ^(.*)$ http://new-example.com/$1 [L,R=301]

Upvotes: 2

Related Questions