问题
I have .htaccess:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) http://%1 [R=302,NE,L]
It works ok when I have redirection from (example): from http:// is redirect to correct https:// from http://www is redirect to correct https:// but when I have https://www. I don't have redirection and "non trusted connection".
What I should change in my htaccess file?
回答1:
Just redirect to https on your second rule too, e.g.
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=302,NE,L]
Not related, but you don't need to capture the path, only use REQUEST_URI.
来源:https://stackoverflow.com/questions/37642550/htaccess-redirect-from-www-https-to-non-www-https