Redirect two links from old domain to new domain

Viewed 15

I'm trying to redirect only 2 links from old domain to new domain not all links from old domain example :

https://old-domain.com/profile/teams  to  https://new-domain.com

and

https://old-domain.com/activities  to  https://new-domain.com

only this this two links

I did

RewriteEngine on
RewriteBase https://old-domain.com/profile/teams
RewriteRule (.*) https://new-domain.com [R=301,L]

RewriteEngine on
RewriteBase https://old-domain.com/activities
RewriteRule (.*) https://new-domain.com [R=301,L]

but I get 500 error

1 Answers

You can use this redirect rule on site root .htaccess of old domain:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)?old-domain\.com$ [NC]
RewriteRule ^(profile/teams|activities)/?$ https://new-domain.com [L,R=301,NC]

Regular expression ^(profile/teams|activities)/?$ matches /(profile/teams or /activities followed by an optional trailing slash.

Related