Redirect IP to domain using SSL
5,196
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.
Related videos on Youtube
Author by
DN0300
Updated on September 18, 2022Comments
-
DN0300 over 1 year
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?
-
DerfK about 8 yearsIf someone enters
https://111.111.11.111/
there is no way to redirect them until after they have securely connected. -
DN0300 about 8 yearsEven when I enter 111.111.11.111 it redirects to 111.111.11.111 before it goes to my domain
-