Htaccess - Rewrite from http to https and www to non-www

前端 未结 1 1631
借酒劲吻你
借酒劲吻你 2021-01-25 12:47

I am trying to rewrite form http to https and www to non-www urls.

Basically if someone goes to http://www.example.com they need to be redirected to https://example.com

相关标签:
1条回答
  • 2021-01-25 13:23

    You can use this single rule for that requirement:

    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} ^www\. [NC]
    RewriteRule ^ https://garrysun.com%{REQUEST_URI} [NE,L,R=301]
    
    # rest of your rules will appear below
    
    0 讨论(0)
提交回复
热议问题