2010-05-04 77 views
3

我想确保我网站上的某些网址始终通过HTTPS访问,而所有其他网址都是通过HTTP访问的。如何强制某些网址使用SSL并强制所有其他网站使用非SSL?

我可以在我的.htaccess文件中找到任何一种情况,但是如果我同时启用了这两种情况,那么我会得到无限的重定向。

我的.htaccess文件是:

<IfModule mod_expires.c> 
# turn off the module for this directory 
ExpiresActive off 
</IfModule> 

Options +FollowSymLinks 
AddHandler application/x-httpd-php .csv 

RewriteEngine On 

RewriteRule ^/?registration(.*)$ /register$1 [R=301,L] 

# Force SSL for certain URL's 
RewriteCond %{HTTPS} off 
RewriteCond %{REQUEST_URI} (login|register|account) 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

# Force non-SSL for certain URL's 
RewriteCond %{HTTPS} on 
RewriteCond %{REQUEST_URI} !(login|register|account) 
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

# Force files ending in X to use same protocol as initial request 
RewriteRule \.(gif|jpg|jpeg|jpe|png|ico|css|js)$ - [S=1] 

# Use index.php as the controller 
RewriteCond %{REQUEST_URI} !\.(exe|css|js|jpe?g|gif|png|pdf|doc|txt|rtf|xls|swf|htc|ico)$ [NC] 
RewriteCond %{REQUEST_URI} !^(/js.*)$ 
RewriteRule ^(.*)$ index.php [NC,L] 

有没有人对我怎么能强制登录,注册,帐户页面是HTTPS迫使所有其他页面不会同时有什么建议?

+0

什么网址触发了无意义的重定向?重写日志的输出是什么? – Artefacto 2010-05-13 05:44:47

+0

您应该知道,通过服务器知道他们在“其他”页面上,SSL的所有艰苦工作已经完成,并且将其强制为非SSL只是额外的工作。 – Jumbogram 2011-05-26 02:49:04

回答