简体   繁体   中英

How do I force to use ssl with htaccess

I want to force my visitors to use https version of my site. Now, it is redirect to https version if I use the site without the "www" tag, but if I type "www.example.xyz" it is not redirect to the https version.

Here is my htaccess file:

RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Have a try with another condition:

RewriteEngine on
RewriteCond   %{HTTPS}  !^on$
RewriteRule   ^         https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM