0

My .htaccess file was

RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
RewriteCond %{REQUEST_URI} ^/(cust1|cust2|cust3)
RewriteRule (.*) /mysitecustomer/$1 [R=301,L]

I wanted to redirect all HTTP to HTTPS so I modified the .htaccess as per this link.

Not Working : http does not redirect to https, it remains on http. For example when I goto site http://www.mywebsite.com it remains at http:// and shows "not secure". I need it to redirect to https so that the "not secure" goes away.

New .htaccess

RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
RewriteCond %{REQUEST_URI} ^/(rb|LakmeLever|Itc)
RewriteRule (.*) /mysitecustomer/$1 [R=301,L]

#http to https redirect
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mywebsite\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [R,L]
#

But still the http is not redirected to https

Edit 1 (Tried did not work)

RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
RewriteCond %{REQUEST_URI} ^/(rb|LakmeLever|Itc)
RewriteRule (.*) /mysitecustomer/$1 [R=301,L]

#Siddharth http to https redirect
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.mywebsite.com [R=301,L]

Edit 2 (Tried did not work)

RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
RewriteCond %{REQUEST_URI} ^/(rb|LakmeLever|Itc)
RewriteRule (.*) /mysitecustomer/$1 [R=301,L]

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

Edit 3 (Tried, did not work)

RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
RewriteCond %{REQUEST_URI} ^/(rb|LakmeLever|Itc)
RewriteRule (.*) /mysitecustomer/$1 [R=301,L]

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

Edit 4 (tried did not work)

RewriteEngine On
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Siddharth
  • 9,349
  • 16
  • 86
  • 148

0 Answers0