How to redirect from www to https www with htacces?

后端 未结 4 1830
北恋
北恋 2021-01-21 15:42

I need to do the following: My current address looks like: https://www.domain.com

I want to redirect with htaccess: www.domain.com TO https://www.domain.com and http:/

4条回答
  •  感动是毒
    2021-01-21 16:42

    You can achieve both redirect in a single rule like this:

    RewriteEngine On 
    
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^ https://www.yourdomain.com%{REQUEST_URI} [R=301,L,NE]
    

提交回复
热议问题