如何为https重写配置htaccess?

时间:2013-11-21 10:53:06

标签: .htaccess https rewrite

我对某些子目录使用https://(/ login,/ admininstration),为此我找到了一些例子 - 但另一方面我要确保所有其他页面重定向到http://。

现在,我通过https://的链接发送用户,但是当他们离开登录区域时,他们会保持在https://模式。

我现在在标准配置中使用RewriteCond:

SetEnv APPLICATION_ENVIRONMENT show
RewriteEngine On

RewriteBase /
RewriteCond %{HTTP_HOST} !^www.xxxseitexxx.de$ [NC]
RewriteRule ^(.*)$ http://www.xxxseitexxx.de/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]

RewriteRule !\.(js|ico|gif|jpg|jpeg|png|css|inc|pdf|csv|zip|rm|mp3|swf)$ index.php

提前致谢!

1 个答案:

答案 0 :(得分:0)

您可以在其他规则之上使用此规则:

# force HTTP for not login or admininstration
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !/admininstration|login/ [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=302]

# force HTTPS for login or admininstration
RewriteCond %{HTTPS} off
RewriteRule ^(admininstration|login)/ https://%{HTTP_HOST}%{REQUEST_URI} [L,NC,R=302]