【问题标题】:Redirect all https to http, except 3 pages [htaccess / php]将所有 https 重定向到 http,除了 3 个页面 [htaccess / php]
【发布时间】:2013-08-01 09:27:45
【问题描述】:

运行一个 wordpress 站点,因此它已经有自己的规则从链接中删除 index.php。此外,每次在 url 中有“cache_img”时,都会应用一个特定的规则。

我需要什么:

  1. 让当前规则继续有效
  2. 如果网址是 https,则用 http (301) 重写,除了 3 页(bookingstep1、bookingstep2、bookingsep3)

我很讨厌 htaccess,这对我来说几乎没有意义,我希望有人可以帮助我。我对 htaccess 或 php 解决方案持开放态度。

这是我目前所拥有的(它可能已经有错误......)

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(cache_img) [NC]
RewriteRule . /index.php [L]
RewriteRule ^cache_img/(.*)x(.*)-(.*)/r/(.*) cache_img/tt.php?src=http://mydomain.com/$4&w=$1&h=$2&zc=$3&q=100

我尝试在我的 htaccess 顶部添加:

RewriteCond %{HTTPS} on
Rewritecond %{REQUEST_URI} !^bookingstep(1|2|3)\/?$ [NC]
RewriteRule ^(.*) http://mydomain.com/$1 [R=301,L]

这适用于所有页面...它删除了 https 并用 http 重写它们。 但它也重写了 bookinstep* 页面:(

请帮忙!谢谢!

【问题讨论】:

    标签: wordpress .htaccess http redirect https


    【解决方案1】:

    试试这个插件:

    http://wordpress.org/plugins/wordpress-https

    我个人一直都在使用它。您可以将每个页面设置为 https,也可以进入单独的页面/帖子并单独确保它们的安全。

    编辑

    RewriteEngine on
    RewriteCond %{SERVER_PORT} =80
    RewriteRule ^bookingstep1/?$ https://URL HERE/bookingstep1[R=301,QSA,L,NE]
    RewriteRule ^bookingstep2/?$ https://URL HERE/bookingstep2[R=301,QSA,L,NE]
    RewriteRule ^bookingstep3/?$ https://URL HERE/bookingstep3[R=301,QSA,L,NE]
    

    【讨论】:

    • 我想避免为此使用插件。问题是没有获得我需要工作的 SSL 页面,问题是一旦你在 HTTPS 中,并浏览到另一个内部页面,那也将自动在 HTTPS 中......这正是我想要避免的。
    【解决方案2】:

    将所有https重定向到http

    代码:

    重写引擎开启 RewriteCond %{SERVER_PORT} ^443$ [OR] RewriteCond %{HTTPS} 开启 重写规则 ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteBase / 重写规则 ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d 重写规则。 /index.php [L]

    更多详情请见here

    【讨论】:

    • 我不得不排除特定页面,所以很遗憾,这不是一个解决方案。
    猜你喜欢
    • 1970-01-01
    • 2011-01-05
    • 2015-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-18
    相关资源
    最近更新 更多