【问题标题】:how is the redirect rule from https://www.domain to http://domain?从 https://www.domain 到 http://domain 的重定向规则如何?
【发布时间】:2021-04-10 07:33:27
【问题描述】:

这是 http 转 https
非 www 到 www

#http -> https
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

#add www.
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

我不知道反码^^;;
https 转 http
www 到非 www

htaccess 中的规则如何? 谢谢

【问题讨论】:

    标签: redirect http-status-code-301


    【解决方案1】:

    要将https 重定向到http 并将www 重定向到non-www,您可以修改您的规则,如下所示:

    RewriteEngine on
    #https -> http
    RewriteCond %{HTTPS} on
    RewriteCond %{HTTP:X-Forwarded-Proto} !http$
    RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
    #add non-www.
    RewriteCond %{HTTP_HOST} ^www\.(.+)  [NC]
    RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [L,R=301]
    

    【讨论】:

      猜你喜欢
      • 2013-09-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-16
      • 1970-01-01
      • 2015-04-19
      • 1970-01-01
      相关资源
      最近更新 更多