我目前有一个SSL证书应用于我的站点,并且所有URL都正确地重定向到https。我需要其中一个URLS是HTTP。我的.htaccess中有以下代码将所有页面重定向到HTTPS。
我希望下面的URL是HTTP而不是HTTPS。
http://www.example.com/blog_rss.php
RewriteEngine on
RewriteBase /
RewriteCond %{ENV:HTTPS} !on [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]提前感谢您的帮助!
发布于 2014-08-22 21:54:57
您可以在htaccess中用此代码替换当前代码。
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/blog_rss\.php$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L,QSA]
RewriteCond %{HTTPS} on
RewriteRule ^(blog_rss\.php)$ http://%{HTTP_HOST}/$1 [R=301,L,QSA]编辑:看起来在某些服务器上无法识别%{HTTPS},这会导致无限循环。
尝试使用%{SERVER_PORT} (如果默认的http端口仍然是80,而ssl端口是443)
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/blog_rss\.php$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L,QSA]
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(blog_rss\.php)$ http://%{HTTP_HOST}/$1 [R=301,L,QSA]您也可以尝试使用初始语法。
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:HTTPS} !on [NC]
RewriteCond %{REQUEST_URI} !^/blog_rss\.php$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L,QSA]
RewriteCond %{ENV:HTTPS} on [NC]
RewriteRule ^(blog_rss\.php)$ http://%{HTTP_HOST}/$1 [R=301,L,QSA]https://stackoverflow.com/questions/25455985
复制相似问题