Redirect non-www and non-http to https

后端 未结 2 1824
不知归路
不知归路 2021-01-02 16:51

Yesterday I Installed SSL on the server. Since than I can\'t reach some pages.

www.example.com/amsterdam/shoes

example.com/amsterdam/

相关标签:
2条回答
  • 2021-01-02 17:16

    Use:

    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    

    OR you can try:

    RewriteEngine On 
    RewriteCond %{HTTP_HOST} ^example\.com [NC]
    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
    
    0 讨论(0)
  • 2021-01-02 17:28
    RewriteEngine on
    
    
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^ https://www.example.com%{REQUEST_URI} [NC,L,R=301,NE]
    

    This will redirect both http or non-www to https://www

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