.htaccess redirect to “https://www”

前端 未结 1 1396
一生所求
一生所求 2021-01-23 17:34

I\'m looking for an .htaccess configuration that will redirect all requests to my site to https://www.

So whether the user visits:

www.examp         


        
相关标签:
1条回答
  • 2021-01-23 18:30

    Your regular expression ^example\.com doesn't match www.example.com. You probably want something like (^|\.)example\.com or (^|\.)example\.com($|:).

    Edit:

    To prevent the redirect loop add

    RewriteCond %{HTTPS} off
    

    Before the RewriteRule.

    Also see http://wiki.apache.org/httpd/RewriteHTTPToHTTPS (they use !=on instead of off) and http://wiki.apache.org/httpd/RedirectSSL

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