Problem distinguishing 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.
精彩评论