title: Problem detecting empty REQUEST_URI with Apache mod_rewrite
body: <p>I am running Apache witha redirect rule like this:</p>
  
  <pre><code>RewriteCond %{HTTP_HOST} ^1st-domain\.com
  RewriteRule ^(.*)$ http://2nd-domain.com$1 [R=permanent,L]
  </code></pre>
  
  <p>This successfully redirects <a href="http://1st-domain.com" rel="noreferrer">http://1st-domain.com</a> to <a href="http://2nd-domain.com" rel="noreferrer">http://2nd-domain.com</a>
  However, when the REQUEST_URI is empty, I want to redirect to a third domain.</p>
  
  <pre><code>RewriteCond %{HTTP_HOST} ^1st-domain\.com$
  RewriteCond %{QUERY_STRING} ^$
  RewriteRule ^(.*)$ http://3rd-domain.com$1 [R=permanent,L]
  </code></pre>
  
  <p>But this does not work and instead redirects to 2nd-domain.com</p>
  
  <p>My rules are ordered like this:</p>
  
  <pre><code>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]
  </code></pre>
  
  <p>Any suggestions? Thank you in advance.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <ol>
  <li>Empty REQUEST_URI:  http:/1st-domain.com</li>
  <li>Non-empty REQUEST_URI:  <a href="http://1st-domain.com/something" rel="noreferrer">http://1st-domain.com/something</a></li>
  </ol>
  
  <p>The first rule should direct an empty request_uri to 3rd-domain.com, the second rule should direct the non-empty request_uri to 2nd-domain.com</p>
  
  <p><strong>USEFUL TIDBIT</strong>
  You can turn on mod_rewrite debug with this snippet:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  RewriteLog "/home/domain.com/logs/rewrite.log"
  RewriteLogLevel 3
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>Very useful debug option I hadn't known.</p>