Redirect to HTTP non-www to HTTPS www htaccess

前端 未结 12 1128
醉话见心
醉话见心 2020-12-01 08:05

I want to redirect from any direction to our site with HTTPS protocol, but some redirects it\'s not working. I want this:

  • http://www.site.co TO
12条回答
  •  半阙折子戏
    2020-12-01 08:50

    For example https://example.com should be going to https://www.example.com

    RewriteEngine On
    RewriteCond %{SERVER_PORT} !=443
    RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
    RewriteRule ^(.*)$ "https\:\/\/www\.example\.com\/$1" [R=301,L]
    

    Note - you should change example.com to your own domain.

提交回复
热议问题