Sarthak  Gupta
Sarthak Gupta

Reputation: 654

How to use htaccess to redirect only certain URL's to a different domain

I have two ecommerce websites abc.com and pqr.com .In a couple of months time I plan to close down abc.com and have started listing all products on pqr.com . How can I redirect only a certain urls on the old website to the new one keeping other URL's as is.

e.g. abc.com/example-product should redirect to pqr.com/example-product abc.com/example-product-2 should not redirect.

Upvotes: 0

Views: 61

Answers (1)

anubhava
anubhava

Reputation: 786339

You can use this rule in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)?abc\.com$ [NC]
RewriteRule ^example-product/?$ http://pqr.com/$0 [L,NC,R=301]

Upvotes: 1

Related Questions