gpt4 book ai didi

linux - .htaccess 中的 https 到 http,但有异常(exception)

转载 作者:太空宇宙 更新时间:2023-11-04 04:29:09 24 4
gpt4 key购买 nike

我已经做了足够的研究,发现要将站点范围内的所有 https 页面重定向到其 http 等效项,我需要使用此代码...

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

我的问题是,有一些页面句柄我仍然想保留为 https。举例来说,假设我希望 page1.php、page2.php 和 page3.php 保留为 .https,而网站上的其他所有内容都进行重定向。有人知道该怎么做吗?

最佳答案

尝试这样的事情:

RewriteEngine On

# Force page1,2,3.php onto HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(page1|page2|page3)\.php https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA]

# Redirect other HTTPS requests to plain HTTP
RewriteCond %{HTTPS} on
RewriteCond ${REQUEST_URI} !(page1|page2|page3)\.php
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA]

关于linux - .htaccess 中的 https 到 http,但有异常(exception),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5409742/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com