使用htaccess禁用单页的https

时间:2015-12-04 08:47:58

标签: php apache .htaccess mod-rewrite url-rewriting

我尝试了一些htaccess的感觉,但它对我不起作用。我需要使用整个站点和https,除了一个页面需要来自另一个站点的http连接,所以我需要为此页面禁用https。

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

RewriteCond %{HTTPS} on
RewriteCond %{SCRIPT_FILENAME} \/exp\.php [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [L,NC]

浏览器说它似乎有太多的重定向。

1 个答案:

答案 0 :(得分:1)

您可以使用以下代码:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} ^off$
RewriteCond %{REQUEST_URI} !exp\.php$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]