.htaccess仅在家中使用SSL而在其他地方使用SSL?

时间:2012-10-25 15:34:03

标签: .htaccess

我希望.htaccess不在主页链接上添加SSL

  

http://domain.com

但网站上的其他所有链接

  

https://domain.com/folder/index.html

因此只有主页不安全。什么是最好的.htaccess配置?

由于

2 个答案:

答案 0 :(得分:1)

使用RewriteRule来匹配{em>在<{1}}之外存在的任何,如果匹配,则重写为SSL:

/

答案 1 :(得分:0)

通过httpd.conf启用mod_rewrite和.htaccess,然后将此代码放在.htaccess目录下的DOCUMENT_ROOT中:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteRule ^.+$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTPS} =on
RewriteRule ^$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]