My site just got its EV SSL certificate. In the past I've redirected non-www requests to www using htaccess - and it worked well.
But now, if I request a https page, I end up (via the htaccess redirect) on the http version.
I need htaccess to redirect like this: non-www redirects to www, while preserving the http or https
Here is the htaccess file I'm using now:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
It i开发者_运维技巧sn't working right. The https requests are being redirected to http.
Try this:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301,QSA]
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301,QSA]
精彩评论