将所有HTTPS重定向到除两个页面之外的HTTP

时间:2014-06-02 15:44:59

标签: apache .htaccess

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

我目前的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网址重定向到http,除了两个/ login /和/ register /

如何确保使用最低条件。

1 个答案:

答案 0 :(得分:0)

除非您坚持使用.htaccess,否则您可以在页面的顶部使用PHP进行http检查并使用标头位置将它们发送到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)

相关问题