简体   繁体   中英

redirect http://www.example.com/ to https://www.example.com/ with htaccess

I am using this as a solution.

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

But I keep getting this error. "Not all versions of your page point to the same URL." Only the URL containing ' http://www.example.com/ does not redirect to the 'https' but rest all redirects properly.

You can do like

RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

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