Redirect HTTP to HTTPS automatically

Το πρόβλημα

Κώδικας
If you have a secure certificate (SSL) on your website, you can automatically redirect visitors to the secured (HTTPS) version of your website

Η λύση

Linux-based accounts use .htaccess files to handle redirection.

Using the following code in your .htaccess file automatically redirects visitors to the HTTPS version of your site:

RewriteEngine On

RewriteCond %{HTTPS} off

RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Κώδικας
If you have an existing .htaccess file:

Do not duplicate RewriteEngine On.

Make sure the lines beginning RewriteCond and RewriteRule immediately follow the already-existing RewriteEngine On.

Σας βοήθησε αυτή η λύση;

← Όλες οι λύσεις