开发者

Problem distinguishing empty REQUEST_URI with Apache mod_rewrite

开发者 https://www.devze.com 2023-02-26 05:19 出处:网络
Merged with Problem detecting empty REQUEST_URI with Apache mod_rewrite. I am running Apache witha redi开发者_StackOverflow中文版rect rule like this:
Merged with Problem detecting empty REQUEST_URI with Apache mod_rewrite.

I am running Apache witha redi开发者_StackOverflow中文版rect rule like this:

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 the REQUEST_URI is empty, I want to redirect to a 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 ordered like this:

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

精彩评论

暂无评论...
验证码 换一张
取 消