2013-03-25 48 views
0

我想配置一些有条件的重定向,我想是这样的:htaccess:打开和关闭特定网址的https?

http://www.example.com/login 
http://www.example.com/login/* 
http://www.example.com/login/account 
http://www.example.com/login/account/* 
https://www.example.com/account 
https://www.example.com/account/* 

我的问题是当前的.htaccess规则迫使/login/account下HTTPS运行,所以我得到这样的:

http://www.example.com/login 
http://www.example.com/login/* 
https://www.example.com/login/account 
https://www.example.com/login/account/* 
https://www.example.com/account 
https://www.example.com/account/* 

这里的现行规则:

<Files .htaccess> 
order allow,deny 
deny from all 
</Files> 

<IfModule mod_rewrite.c> 
RewriteEngine On 

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ - [E=site_url:http://www.example.com] 
RewriteCond %{SERVER_PORT} 443 
RewriteRule ^(.*)$ - [E=site_url:https://www.example.com] 

RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} /account 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L] 

RewriteCond %{SERVER_PORT} 443 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !(/account) 
RewriteRule ^(.*)$ http://www.example.com/$1 [R,L] 

我想这个问题是与RewriteCond %{REQUEST_URI} !(/account)规则。我尝试了很多变化,并在各处搜索,但没有找到任何符合我想要做的事情。

所以只是为了澄清/account以下的everthing必须是https一切应该是http。

有关信息,这是表达式引擎网站,所以这些不是物理文件或目录,但动态生成的URL。

任何帮助将不胜感激。

回答

1

尝试......

RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} /account 
RewriteCond %{REQUEST_URI} !(login/account) 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L] 

RewriteCond %{SERVER_PORT} 443 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !(/account) 
RewriteCond %{REQUEST_URI} (login/account) 
RewriteRule ^(.*)$ http://www.example.com/$1 [R,L] 

ExpressionEngine HTTPS/HTTP的具体的例子: https://expressionengine.stackexchange.com/questions/7601/adding-a-htaccess-redirect-to-https-that-plays-nicely-with-existing-ee-htacces/7659#7659

+0

感谢您的,但没有运气,还是得到同样的结果。感谢您的链接,我会看看,看看我能不能弄明白。 – neilkb 2013-03-27 08:56:35

+0

经过许多调整后,我终于在那里对您的建议进行了一些修改。所有'RewriteCond'语句都需要包含'/ account?。*',但这只是特定于我的特定站点。谢谢 – neilkb 2013-03-27 13:40:40