Tags
MySQL
Asked 2 years ago
16 Feb 2022
Views 470
kord

kord posted

redirect http to https forcefully by .htaccess

i have installed the SSL to my server but somehow some links come to without SSL like http , so i want to redirect it http to https

so i want some code for htaccess so it redirect http request to https forcefully






ajamil

ajamil
answered Feb 16 '22 00:00


.htaccess code will be like to force http request to https is belowed

<IfModule mod_rewrite.c>

RewriteEngine On 
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>


RewriteCond %{HTTPS} off
will check is current request is without ssl than
redirect to same url to https version of the url
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Post Answer