Redirect http url to https url using htaccess

前端 未结 1 638
予麋鹿
予麋鹿 2020-12-22 11:47

I using below code in the htaccess file to redirect www to non www domain and the requirement as below.

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^w         


        
相关标签:
1条回答
  • 2020-12-22 12:33

    I use this:

    RewriteEngine On
    # the following line is only needed, if HTTP and HTTPS share the same config
    RewriteCond %{HTTPS} off
    RewriteCond %{REQUEST_FILENAME} !^/.well-known/
    RewriteRule .* https://wiimmfi.de$0 [R=301,L]
    

    I excluded /.well-known/ to update the let's encrypt certificates.

    Inside a <directory> or for .htaccess:

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteCond %{REQUEST_FILENAME} !^.well-known/
    RewriteRule .* https://wiimmfi.de/$0 [R=301,L]
    
    0 讨论(0)
提交回复
热议问题