htaccess redirect to https://www

前端 未结 14 2019
夕颜
夕颜 2020-11-21 11:01

I have the following htaccess code:



RewriteEngine On
RewriteCond !{HTTPS} off
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{RE         


        
14条回答
  •  无人共我
    2020-11-21 11:55

    Similar to Amir Forsati's solution htaccess redirect to https://www but for variable domain name, I suggest:

    RewriteEngine on
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteCond %{HTTP_HOST} ^(www\.)?(.+)$ [NC]
    RewriteRule ^ https://www.%2%{REQUEST_URI} [R=301,L]
    

提交回复
热议问题