I’ve successfully installed “Let’s Encrypt” on my website. It works fine, but when someone tries to visit my website and not type “https” in the beginning, it’ll load the “http” URL.
My question is: How to redirect all “http” URLs to “https”?
If its apache you can add it via .htaccess or web config
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [NC,R=301,L]
If its Nginx , add it in your config
rewrite ^ (.*) https://$host$request_uri? permanent;
// note : $host/$server_name
or
return 301 https://$server_name$request_uri;
Ok. So the only thing I need is to change values of RewriteEngine, RewriteCond and RewriteRule and instead of SERVER_PORT and SERVER_NAME write my own concrete port and name. Is that so?