开发者

Force SSL just for a specific page

Right now the whole site is configured to use SSL in Apache, but I would like to use SSL just for a specific page. Let's say:

http://www.mydomain.com/purchase/buy/28  

So everything inside purchase/ (buy, cancel, check, whatever) must be encrypted. What are the Apache and mod_rewrite rules to accomplish that?

I have tried with:

RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [L,R]

RewriteCond %{SERVER_PORT} !443
RewriteRule (.*) https://www.mydomain.com/city/ [R]

R开发者_开发问答ewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

But had no luck :(.


This should do the trick:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} purchase
RewriteRule ^(.*)$ https://www.mydomain.com/purchase/$1 [R,L]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜