Force HTTPS redirection

 

Question : How do I force redirection from http to https on premium or free hosting.

Answer : in your sites .htaccess file add the following lines :

RewriteEngine On
RewriteCond %{ENV:HTTPS} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


You may use the following lines to force both HTTPS and WWW :

RewriteEngine On
RewriteCond %{ENV:HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www.YOURDOMAIN.COM$ [NC]
RewriteRule ^(.*)$ https://www.YOURDOMAIN.COM/$1 [L,R=301]

  • 87 Пользователи нашли это полезным
Помог ли вам данный ответ?

Связанные статьи

Owncloud login fails

Question : After installing OwnCloud I am unable to login Answer : Log into your cPanel, and...

wordpress running slow

The following plugin will help WP use less server resources and speed up your website...