0

我有一个在 drupal 上运行的网站。服务器已启用 https。现在,我想在 htp 中运行所有页面,除了几个页面,例如:

http://www.mysite.com/

http://www.mysite.com/tour.html

http://www.mysite.com/contact-us.html

例外

https://www.mysite.com/buynow.html

https://www.mysite.com/signup.html

如何使用 .htaccess 或安装任何模块来做到这一点?

提前致谢!

4

2 回答 2

0

您还可以使用securepages模块来实现这一点。

有关 Drupal 中的 https 和安全性的更多信息,有一个非常好的文档

于 2013-07-27T12:18:33.973 回答
0

我假设,当人们请求 buynow.html 或 signup.html 时,您希望将他们重定向到 https。对于您希望他们使用 http 的其他页面。试试这个.htaccess:

RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} (^/buynow.html)|(^/signup.html)
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L]


RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/buynow.html
RewriteCond %{REQUEST_URI} !^/signup.html
RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [L]

更新

新的.htaccess:

<IfModule mod_rewrite.c>
      RewriteEngine on

      RewriteRule (.*) $1 [E=protossl]
      RewriteCond %{HTTPS} on
      RewriteRule (.*) $1 [E=protossl:s]

      RewriteRule "(^|/)\." - [F]

      RewriteCond %{HTTP_HOST} .
      RewriteCond %{HTTP_HOST} !^www\. [NC]
      RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

      RewriteCond %{HTTPS} !=on
      RewriteCond %{REQUEST_URI} (^/buynow.html)|(^/signup.html)
      RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L]

      RewriteCond %{HTTPS} on
      RewriteCond %{REQUEST_URI} !^/buynow.html
      RewriteCond %{REQUEST_URI} !^/signup.html
      RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [L]

      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_URI} !=/favicon.ico
      RewriteRule ^ index.php [L]
</IfModule>
于 2013-07-27T07:41:50.117 回答