I am trying to redirect my IP address to my domain which uses SSL. In my htaccess
I am using following lines:
RewriteCond %{HTTP_HOST} ^111\.111\.11\.111$ RewriteRule ^(.*)$ https://domain.com/$1 [L,R=301]
Redirect works, but before it is redirected I get SSL certificate error, once I click on proceed (unsafe) it goes to the domain. How do I redirect to domain without going to to the SSL certificate page first?
Answer
For this to be possible, you would need a valid SSL certificate for 111.111.11.111
, which is unlikely, see also Is it possible to have SSL certificate for IP address, not domain name?.
What you probably want to do is:
- Create a
VirtualHost
entry matching111.111.11.111
asServerName
, but not usinghttps
, buthttp
instead. - Redirect that to your domain.
You might also consider using mod_alias
instead of mod_rewrite
, which is considered the cleaner options in this case, see When not to use mod_rewrite.
Attribution
Source : Link , Question Author : DN0300 , Answer Author : Community