Changing htaccess to redirect to https site

alt=
duke
@musamensa
6 years ago
253 posts
Hi guys,
please I would like to change edit the htaccess file so that all requests are directed to https site, what line of code do i need to add to make this happen ?

Thanks
updated by @musamensa: 04/19/18 07:47:41AM
Black-Eagle
Black-Eagle
@black-eagle
6 years ago
57 posts
Hello Musamensa.

You can add the following code in the ..htaccess file :

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

It's work on my website.
updated by @black-eagle: 01/19/18 03:50:20AM
alt=
duke
@musamensa
6 years ago
253 posts
thanks will give it a shot

Tags