Akshay Trivedi
Akshay Trivedi

Reputation: 33

Not Directing Http/www traffic to HTTPS

so I have installed ssl certificate on my server, so if search using https://www.domain.info its secure connection. but if i search using www.domain.info or http://www.domain.info it doesnt redirect to https for a secure connection.

this is my current htaccess content


RewriteEngine On

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]

Upvotes: 1

Views: 60

Answers (1)

RavinderSingh13
RavinderSingh13

Reputation: 133538

Looks like your htaccess file is not enabled mod rewrite rule at present, try un-commenting line LoadModule rewrite_module modules/mod_rewrite.so once. Plus go through article https://phoenixnap.com/kb/how-to-set-up-enable-htaccess-apache for understanding on how to enable htaccess file.

Also change your rules to following.

RewriteEngine On

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

Upvotes: 2

Related Questions