htaccess redirect code not working

pardis

Well-Known Member
#1
Hi

I want redirect all non-ssl query to https on my domain , all code working on apache but on lsws not working even cpanel code :

Code:
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteCond %{HTTP_HOST} ^domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.com$
RewriteRule ^(.*)$ "https\:\/\/domain\.com\/$1" [R=301,L]

Can you duide about this ? and tell me whay almost code working on apache but not working on lsws ?

Thanks
 

serpent_driver

Well-Known Member
#2
Your code is insufficient. This will work for you with Apache && LiteSpeed

Code:
  RewriteCond %{SERVER_PORT} !^443$
  RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L] 
  RewriteCond %{HTTP_HOST} !^www\.
  RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]
 
Top