https non www to https www

后端 未结 1 441
庸人自扰
庸人自扰 2021-01-26 17:52

i rewrite all non-www requests to www with:

RewriteCond %{HTTP_HOST} !^www\\.mydomain\\.de$
RewriteRule ^(.*)$ http://www.mydomain.de/$1 [L,R=301]
1条回答
  •  逝去的感伤
    2021-01-26 18:03

    You can use this code:

    ## add www to a domain name
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteCond %{HTTPS}s on(s)|
    RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    

    This will perform:

    • https => https with www rewrite
    • http => http with www rewrite

    0 讨论(0)
提交回复
热议问题