【问题标题】:Redirecting all HTTPS to HTTP except two pages将除两个页面外的所有 HTTPS 重定向到 HTTP
【发布时间】:2014-07-22 19:11:24
【问题描述】:

我尝试了本网站其他主题的一些帮助,但遇到了重定向循环错误。

我当前的 htaccess 代码:-

RewriteEngine on

RewriteCond %{SERVER_PORT} ^80$

RewriteCond %{HTTP_HOST} !^www\.

RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteRule ^([^.]+)/?$ index.php?v=$1 [QSA,L]

RewriteEngine on

RewriteCond %{SERVER_PORT} ^443$

RewriteCond %{HTTP_HOST} !^www\.

RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteRule ^([^.]+)/?$ index.php\?v=$1 [QSA,L]

以上内容与此问题无关,但为了获得您的适当帮助,我已将其包含在内。

现在我想将所有 https url 重定向到 http 除了两个 /login/ 和 /register/

如何确保使用最低条件。

【问题讨论】:

    标签: apache .htaccess


    【解决方案1】:

    除非您习惯使用 .htaccess,否则您可以在要访问 http 的页面顶部使用 PHP 检查并使用标头位置将它们发送到 http。

    if($_SERVER['SERVER_PORT'] == 443)
        header('Location: http://'.$_SERVER['HTTP_HOST'].'/'.$rest_of_path);
    

    这里有一些关于如何构建整个 url 以便它们进入同一页面的好信息。 Getting the full URL of the current page (PHP)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-05
      • 1970-01-01
      • 2013-08-01
      • 2016-09-16
      相关资源
      最近更新 更多