问题
I'd like to redirect all the pages that I have in my site example.com into https://www.example.com/..
In my htaccess file I have this code that works only from all the http pages to https pages but doesn't work from non-www pages to www pages (shows error "ERR_CONNECTION_REFUSED").
Options -MultiViews
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s on(s)|offs()
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R]
# Redirect to HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Works in these cases (each of pages .php) from:
http://example.com/page.php to https://www.example.com/page.php http://www.example.com/page.php to https://www.example.com/page.php
Doesn't work only in these cases (each of pages .php) from:
https://example.com/page.php to https://www.example.com/page.php
来源:https://stackoverflow.com/questions/49626411/htaccess-redirect-https-example-com-to-https-www-example-com