Remove www site-wide, force https on certain directories and http on the rest?

前端 未结 4 1332
野的像风
野的像风 2020-12-08 05:50

Firstly, I would like to remove the www. from my domain name

http://www.example.com => http://example.com

I would also like for certain directories to be sec

4条回答
  •  有刺的猬
    2020-12-08 06:10

    This code works for me:

    
    
       RewriteEngine on
    
       RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
       RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
    
       RewriteCond %{HTTPS} !=on
       RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
    
    
    

提交回复
热议问题