嗨,我一直在研究这个问题,只知道我做了一些愚蠢的事,但却看不到它。我想要做的是重定向某些页面,以便它们始终使用HTTPS和所有其他页面显示,如果通过HTTPS请求它们将它们重定向为HTTP。
我已经围绕这个问题进行了大量搜索,并在Stackoverflow上找到了对我不起作用的接受答案。所以这是我的.htaccess文件。
RewriteCond %{HTTPS} on
RewriteCond ${REQUEST_URI} !(finance/enquiryForm)(.*)
RewriteCond ${REQUEST_URI} !(offerentry)(.*)
RewriteRule (.*) http://dev.staging.co.uk/$1 [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(finance/enquiryForm|offerentry)(.*) https://dev.staging.co.uk/$1 [L,R=301]
目前正在发生的事情是,我想要从https重定向到http的页面工作正常,但我想要显示为HTTPS的页面获得重定向循环并失败。如果我在HTTPS页面的顶部注释掉,我确实想要重定向。那么如何让重定向循环停止?
修改 带有codeigniter等内容的完整.htaccess文件。
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
<Files .*>
Order Deny,Allow
Deny From All
</Files>
#RewriteCond %{HTTPS} on
#RewriteCond ${REQUEST_URI} !/(finance/enquiryForm|offerentry) [NC]
#RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=302,NE]
#RewriteCond %{HTTPS} off
#RewriteCond ${REQUEST_URI} /(finance/enquiryForm|offerentry) [NC]
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=302,NE]
# Protect application and system files from being viewed
RewriteRule ^(fuel/install/.+|fuel/crons/.+|fuel/data_backup/.+|fuel/codeigniter/.+|fuel/modules/.+|fuel/application/.+|\.$
# Remove trailing slashes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)/$
RewriteCond %{REQUEST_URI} !fuel/.*$
RewriteRule ^(.*)/$ $1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [L]
</IfModule>
Options -Indexes
答案 0 :(得分:1)
根据THE_REQUEST
变量
RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} !/(finance/enquiryForm|offerentry) [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=302,NE]
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} /(finance/enquiryForm|offerentry) [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=302,NE]
在Chrome开发工具中测试它们,看看你得到了哪些重定向。
答案 1 :(得分:0)
尝试:
public class MenuController : Controller
{
public ActionResult TreePanelClickHandler(string param1,string param2,string param3)
{
X.Msg.Alert("server-side:", param1 + "\n" + param2+ "\n" + param3).Show();
AjaxResult r = new AjaxResult();
return r;
}
}