Question
Redirect From HTTP to HTTPS
Hey, I recently installed Lets Encrypt SSL, its successful however it wont redirect whenever its on http. So how to redirect all to https??
Here method I already tried but it seems wont working:
1 .htaccess
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTPHOST}%{REQUESTURI}
- Redirect PHP Function
< ?php
function redirectTohttps() {
if($SERVER[‘HTTPS’]!=”on”) {
$redirect= “https://”.$SERVER['HTTPHOST’].$SERVER['REQUEST_URI’];
header(“Location:$redirect”); } }
?>
- HTML Meta Tag
< meta http-equiv=“Refresh” content=“0;URL=https://www.example.com” />
Note*: This method works however it cause infinite loop and crash the server.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×
If you can, use the virtual host in terminal(command line) of your server, and change “Redirect Permanent” to the https version.. and then it will be redirected with entered as http.. or www… etc
Just add this into apache site config and change the domain.
It works for me, thanks!
Gracias funciono.
It works for me too, thank you so much @KorencSoft !