Problem of difference between empty REQUEST_URI and Apache mod_rewrite

I start Apache with a redirect rule as follows:

RewriteCond %{HTTP_HOST} ^1st-domain\.com RewriteRule ^(.*)$ http://2nd-domain.com$1 [R=permanent,L] 

This successfully redirects http://1st-domain.com to http://2nd-domain.com However, when REQUEST_URI is empty, I want to redirect to the third domain.

 RewriteCond %{HTTP_HOST} ^1st-domain\.com$ RewriteCond %{QUERY_STRING} ^$ RewriteRule ^(.*)$ http://3rd-domain.com$1 [R=permanent,L] 

But this does not work and instead redirects to 2nd-domain.com

My rules are organized as follows:

 RewriteCond %{HTTP_HOST} ^1st-domain\.com$ RewriteCond %{QUERY_STRING} ^$ RewriteRule ^(.*)$ http://3rd-domain.com$1 [R=permanent,L] RewriteCond %{HTTP_HOST} ^1st-domain\.com RewriteRule ^(.*)$ http://2nd-domain.com$1 [R=permanent,L] 

Any suggestions? Thank you in advance.

0
source share

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


All Articles