0

How to force SSL with htaccess With this code i get a redirect error in chrome:

RewriteEngine On  
RewriteCond %{HTTPS} !^on$ [NC]  
RewriteRule . https://%{HTTP_HOST}/%{REQUEST_URI} [L] HTTPS_HOST ???

Thanks

Croises
  • 18,570
  • 4
  • 30
  • 47
user3135461
  • 11
  • 1
  • 4
  • don't do that. set up a separate vhost for your non-ssl version and put a an unconditional `RedirectPermanent` directive in there. – Marc B Jan 26 '15 at 22:14
  • I only have webspace i don't have access to that files on server. Is there any other way to force ssl? – user3135461 Jan 26 '15 at 22:16
  • Possible duplicate of [Force SSL/https using .htaccess and mod\_rewrite](http://stackoverflow.com/questions/4398951/force-ssl-https-using-htaccess-and-mod-rewrite) – lpd May 16 '16 at 18:50

2 Answers2

0

You can use that:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301] 
Croises
  • 18,570
  • 4
  • 30
  • 47
0

I suggest you use this code and its working fine

#Force SSL

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Shiv Singh
  • 6,939
  • 3
  • 40
  • 50