将URL重写为HTTP到HTTPS,但有一个特定例外

问题描述:

我在我的网站上有一个付款页面:domain.com/user/payment/product_name我想确保所有来到此页面的请求都将被重定向到HTTPS在htaccess中。 “product_name”是一个参数。将URL重写为HTTP到HTTPS,但有一个特定例外

这是我当前的代码:

RewriteCond %{HTTPS} off 
RewriteCond ^([^/]+)/payment/([^/]+)$ [NC] 
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1/payment/$2 [R=301,L] 

我不知道我在做什么错。

此外,我希望如果用户打开一个页面使用HTTPS的任何页面,除了付款页面,被重定向到HTTP。

谢谢。

RewriteCond %{HTTPS} off 
RewriteRule ^(.*)/payment/([a-zA-Z0-9\-])(/?.*)$ https://domain.com/$1/payment/$2$3 [R=301,L,QSA] 
+0

对不起,我忘了说“product_name”这是一个参数 – morandi3 2012-03-29 18:14:50

+0

现在检查它! – undone 2012-03-29 18:39:35

+0

以及如果“用户”它也是一个参数/变量? – morandi3 2012-03-30 08:32:44