apache redirect http to https and www to non www

后端 未结 6 1650
陌清茗
陌清茗 2020-11-27 18:03

basically what i want is redirect al request to use HTTPS instead of http

I have this in my htaccess so far and it worked great: Code:



        
6条回答
  •  佛祖请我去吃肉
    2020-11-27 18:39

    You can get what you need from the HTTP_HOST

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

    This way it will get the host always without the subdomain.

提交回复
热议问题