title: apache httpd - RewriteCond SERVER_NAME not equal to SERVER_ADDR
body: <p>I need to redirect the user if the <code>SERVER_ADDR</code> and <code>SERVER_NAME</code> variables don't match. </p>
  
  <p>I have the following rule in my httpd.conf file:</p>
  
  <pre><code>RewriteEngine on
  RewriteCond %{SERVER_NAME} !%{SERVER_ADDR}
  RewriteRule .* /myRedirectPage.html [PT]
  </code></pre>
  
  <p>When SERVER_NAME and SERVER_ADDR don't match, I correctly get redirected. <strong>However, I also get redirected even when they are matching.</strong></p>
  
  <p>If I use the following condition it works for both matching and non-matching scenarios: (where 192.168.1.1 is the server IP)</p>
  
  <pre><code>RewriteCond %{SERVER_NAME} !192.168.1.1
  </code></pre>
  
  <p>To check if the variables matched, I used PHP's <code>$_SERVER['SERVER_NAME']</code> and <code>$_SERVER['SERVER_ADDR']</code> variables.</p>
  
  <p>How should I write the RewriteCond so that it does not redirect the user if <code>SERVER_NAME</code> and <code>SERVER_ADDR</code> match?</p>