How to redirect from www to https www with htacces?

后端 未结 4 1777
北恋
北恋 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:28

    Both nonWWW to WWW and http to https solutions:

    ## Redirecting HTTP to HTTPS
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    
    ## Redirecting non WWW to WWW
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain\.tld$ [NC]
    RewriteRule ^(.*)$ http://www.domain.tld/$1 [R=301,L]
    

提交回复
热议问题