.htaccess RewriteCond for a specific page

I currently have a site on one domain, and it has another domain mapped to it. I have a .htaccess RewriteCond as below:

RewriteCond %{HTTP_HOST} ^www\.additional-domain\.com [NC] RewriteRule (.*) http://www.main-domain.com$1 [R=301,L] 

This, obviously, means that any pages that can be accessed by going to www.additional-domain.com will be redirected to the correct page at www.main-domain.com.

What I would like to know is, can I keep this rule, but have certain pages not redirect? therefore, for the page / this -page.html, if the user accessed www.additional-domain.com/this-page.html, they are not redirected to www.main-domain.co.uk/this -page.html

Is it possible? Thanks.

-------- EDIT --------

I forgot to mention that for these extra pages, I want the redirect to work the other way around.

So, if someone turned to www.main-domain.co.uk/this-page.html, they will be redirected to www.additional-domain.co.uk/this-page.html

+4
source share
1 answer

Add additional conditions to the redirect rule:

 RewriteCond %{REQUEST_URI} !/this-page\.html RewriteCond %{REQUEST_URI} !/this-page2\.html RewriteCond %{HTTP_HOST} ^www\.additional-domain\.com [NC] RewriteRule (.*) http://www.main-domain.com$1 [R=301,L] 
+5
source

Source: https://habr.com/ru/post/1494319/


All Articles