【问题标题】:Https to http rewrite rule for Rackspace Cloud site not workingRackspace Cloud 站点的 Https 到 http 重写规则不起作用
【发布时间】:2013-11-05 11:39:14
【问题描述】:

我正在尝试将所有 ssl 请求路由到非 ssl 和以下情况下工作正常,除了一个 [下面列表中的第 4 个],我不确定出了什么问题,你能帮我解决这个问题吗

1 - http://www.domain.com -- 重定向到 www.domain.com - --> 工作正常

2 - http://domain.com -- 重定向到 www.domain.com --> 按预期工作

3 - https://domain.com -- 重定向到 www.domain.com --> 按预期工作

4 - https://www.domain.com -- 重定向到 https://www.domail.com -- 预期为 www.domain.com

        <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteRule .* - [E=W3TC_ENC:_gzip]
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} =""
    RewriteCond %{REQUEST_URI} \/$
    RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
    RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index.html%{ENV:W3TC_ENC}" -f
    RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index.html%{ENV:W3TC_ENC}" [L]
    </IfModule>

    <IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
    RewriteCond %{HTTPS} on
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
    <IfModule>

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
    RewriteCond %{HTTPS} on
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
    <IfModule>

在这里,我想将来自https://www.domain.com 的所有请求重定向到 www.domain.com,下面是我们拥有的 .htaccess 配置详细信息,

谢谢,非常感谢您的支持..

- 马诺杰

【问题讨论】:

  • 只是为了确保我理解这里想要的结果,您希望将所有请求发送到端口 80,但要确保 www.是否包含在网址中?

标签: .htaccess mod-rewrite url-rewriting rackspace-cloud rackspace


【解决方案1】:

去掉这些行:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

(有两组)

您不希望它们在那里,因为 您将所有内容都路由到 index.php

相反,在RewriteRule ^index\.php$ - [L] 行之前添加:

RewriteCond %{HTTPS} on [OR]
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

【讨论】:

    【解决方案2】:

    Rackspace 云服务器在解密 SSL 的负载平衡器后面运行,因此永远不会满足 RewriteCond %{HTTPS} 条件。

    【讨论】:

      猜你喜欢
      • 2015-08-10
      • 1970-01-01
      • 2013-06-02
      • 2019-09-14
      • 2012-06-07
      • 2014-10-16
      • 2019-08-03
      • 1970-01-01
      • 2022-08-12
      相关资源
      最近更新 更多