Ad

One Htaccess For Multiple Domain, Redirect Problem

I have multiple domains and one htaccess for these. We split off some content from domain1.com to domain2.com and I need to redirect to the new page.

Redirect 301 /folder/page.html https://www.domain2.com/folder/page.html

resulted in a infinity loop ... i also tried this but its dont work:

RewriteCond %{HTTP_HOST} ^domain1.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain1.com$
RewriteRule ^/folder/page.html https://www.domain2.com/folder/page.html [R=301,L]

I also need to mention that not all pages from domain1 should redirect to domain2 but it would be ok if the whole folder is redirected

my knowledge of htaccess isnt that big hope you can help me!

Ad

Answer

Based on your shown samples, could you please try following. Please place this to the top of your htaccess file.

Also please make sure to clear your browser cache before testing your URLs.

RewriteEngine ON
RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com$ [NC]
RewriteRule ^folder/page\.html https://www.domain2.com/folder/page.html [R=301,NC,L]
Ad
source: stackoverflow.com
Ad