Reputation: 5071
There are a lot of answers here at Stack Overflow regarding the redirection via htaccess and I have some basic understanding about this. Instead of redirecting the same paths to the new domain, I need these results:
Please note in condition 2 that I want to redirect the subpages to different paths on new domain. The first part is easy for me but the second one challenges me. How can I achieve these results (for 301 redirect)?
Upvotes: 1
Views: 58
Reputation: 143856
Try:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^$ https://www.newdomain.com/ [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^example-page$ https://www.newdomain.com/somepage [L,R=301]
Alternatively, if you are using mod_alias to do the redirecting, then your second redirect needs to be a RedirectMatch
and not the Redirect
directive:
RedirectMatch 301 ^/example-page https://www.newdomain.com/somepage
Upvotes: 1