现在整个站点都配置为在Apache中使用SSL,但我想仅针对特定页面使用SSL。让我们说:
http://www.mydomain.com/purchase/buy/28
因此purchase/
内的所有内容(购买,取消,检查等等)都必须加密。什么是Apache和mod_rewrite规则来实现这一目标?
我尝试过:
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [L,R]
RewriteCond %{SERVER_PORT} !443
RewriteRule (.*) https://www.mydomain.com/city/ [R]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
但没有运气:(。
答案 0 :(得分:2)
这应该可以解决问题:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} purchase
RewriteRule ^(.*)$ https://www.mydomain.com/purchase/$1 [R,L]