title: apache rewrite: force https and name of server, not IP
body: <p>I want my apache to always force people to use https and to map IP based look ups to be forwarded to the server name. The following settings (in httpd.conf file) take care of the http to https redirect:</p>
  
  <pre><code>&lt;Location /&gt;
      Options +FollowSymLinks
      RewriteEngine On
      RewriteCond %{HTTPS} off
      RewriteRule (.*) https://my_server.example.com%{REQUEST_URI}
  &lt;/Location&gt;
  </code></pre>
  
  <p>But now I also want that if people type 192.168.1.2 they get redirected to my_server.example.com.
  To sum up:</p>
  
  <pre><code>http://192.168.1.2/someurl -&gt; https://my_server.example.com/someurl
  </code></pre>
  
  <p>I've tried several things but either my settings get ignored or I end up in a redirect loop.
  any hints?</p>