title: Website not redirecting properly, Google indexed IP address instead of domain, htaccess coding
body: <p>few days ago I have asked my host to install an SSL certificate, to be able to load my website through https protocol. The website is now running via https properly, but I noticed that Google started indexing my website by using the IP Address instead of the domain name and this is caused some pages not being indexed properly.</p>
  
  <p>After the certificate was installed, I created an .htaccess with the following code:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^11\.11\.11\.111$ [NC,OR]
  RewriteCond %{HTTP_HOST} ^([a-z.]+)?example\.com$ [NC]
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteCond %{SERVER_PORT} 80
  RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>(IP and DOMAIN are masked, if you need actual IP and domain, I can provide them)</p>
  
  <p>I was expecting all requests via IP address and via "www.example.com" to be redirected properly to "<a href="https://example.com" rel="nofollow noreferrer">https://example.com</a>" with https protocol and without www.</p>
  
  <p>Unfortunately, if I try to type "<a href="http://11.11.11.111/" rel="nofollow noreferrer">http://11.11.11.111/</a>" I'm being redirected properly to "<a href="https://example.com/" rel="nofollow noreferrer">https://example.com/</a>" but if I try "<a href="https://11.11.11.111/" rel="nofollow noreferrer">https://11.11.11.111/</a>" I am not and I get a warning (of course the certificate is not for IP address, but for domain name).</p>
  
  <p>How can I force redirecting also for https + IP Address by using an htaccess declaration?</p>
  
  <p>Can you please tell me what I'm doing wrong?</p>
  
  <p>Thank you very much in advance for any help.</p>