douzinei6926 2017-09-13 14:38
浏览 50

如何将所有内容重定向到ssl和index.php但不是ssl,而是将所有内容重定向到特定页面上的index.php

I want all to force redirect to https but not on a specific page currently i have this .htaccess file:

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]

I want all to redirect to https but force http on a specific page: /exchage

What code do I need to put on my .htaccess file to achieve this function? Thanks.

  • 写回答

2条回答 默认 最新

  • dongxiong1941 2017-09-13 16:19
    关注

    What about adding another condition to the HTTPS redirect to check that the path doesn't start with exchange? (I assume you misspelled exchage)

    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/exchange
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    RewriteCond %{REQUEST_URI} ^/exchange
    RewriteCond %{HTTPS} on
    RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]
    

    Once you have updated your .htaccess file, please restart your browser. Otherwise it might force https if it has previously seen the URL use https.

    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程