dongqiao0953 2016-07-08 05:38
浏览 25

url rewrite - 重定向到除一个页面之外的HTTP

I would like to have one single page mysubdir/checkout.php to be secured using SSL. e.g. https://www.mywebsite.com/fr/checkout, where fr is the language code.

All other pages should be redirected back to http.

This is what I have in .htaccess but it does not work.

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/fr/checkout
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/fr/checkout
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

##### Checkout #####
RewriteRule ^/(fr|en)/checkout/?$ mysubdir/checkout.php?lang=$1 [QSA]

However when I entered: https://www.mywebsite.com/fr/checkout it redirects to https://www.mywebsite.com/mysubdir/checkout.php?lang=fr. Why?

Any solution to this?

  • 写回答

2条回答 默认 最新

  • du1843 2016-07-08 05:46
    关注

    Try :

    RewriteEngine on
    #redirect checkout.php from http to https
    RewriteCond %{HTTPS} off
    RewriteRule checkout\.php$ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R]
    #redirect all requests except "checkout.php" from https to http
    RewriteCond %{HTTPS} on
    RewriteRule !checkout\.php$ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R]
    

    This will redirect only /checkout.php to https.

    评论

报告相同问题?

悬赏问题

  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码