1.37 Puncte = 1 Vella / Vella= 0.00002667583 BTC si 43.2183406114 Doge

How do I redirect HTTP to HTTPS?

Sencuart

Well-Known Member
Registered
Active Member
Oracol (XOR)
295.34
Fan Adevărat!
0.00 Puncte
#2
You can use HTTPS if you have an SSL certificate and if this certificate is installed correctly on the server. Redirecting can be done in the .htaccess file, which is at the root of your site. Add the following code in .htaccess.

Code:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

If you want to redirect a page or use the code in a PHP file, you can solve it here:

Code:
< ?php function redirectTohttps() { if($_SERVER['HTTPS']!="on") { $redirect= "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; header("Location:$redirect"); } } ?>
If you want to redirect a page or use the code in an HTML file, you can solve it here:

Code:
< meta http-equiv="Refresh" content="0;URL=https://www.example.com" />
 
Top