htaccess for redirecting non-www to www while preserving http & https

后端 未结 1 467
执念已碎
执念已碎 2021-01-25 18:47

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

相关标签:
1条回答
  • 2021-01-25 19:19

    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]
    
    0 讨论(0)
提交回复
热议问题