我想确保我的网站上的某些网址始终通过HTTPS访问,而所有其他网址都是通过HTTP访问的。
我可以在我的.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 :(得分:1)
对于未加密的连接,您似乎匹配HTTPS = on和HTTPS = off。
您应该仔细检查是否按预期设置了HTTPS环境变量。否则会有无限重定向 - 正如您所经历的那样。