php - 将一页重定向到 http 而不是 https

标签 php .htaccess ssl

我有如下所示的 .htaccess 文件,用于对我的所有页面强制使用 https。

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?example\.net
RewriteRule ^(.*)$ https://www.example.net/$1 [R,L]

它按照我的要求工作正常。现在我想为我的一个名为 demo.html 的页面排除 https 我不想要 https。 它的需要

http://example.net/demo.html 

而不是

https://example.net/demo.html

最佳答案

您需要为其添加RewriteCond条件。

检查以下代码:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?example\.net
RewriteCond %{REQUEST_URI} !^/demo\.html$ [NC]
RewriteRule ^(.*)$ https://www.example.net/$1 [R,L]

关于php - 将一页重定向到 http 而不是 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54453439/

相关文章:

php - Cakephp 2.x 停放域 https 不工作

wordpress -/wp-admin/&/wp-login.php 重定向循环

java - 是否可以使用 Java SDK 通过反向代理连接到 Azure Cosmos DB?

php - 没有 php 错误登录 apache

javascript - selectbox 多个而不被选中

php - 尝试结合两个 Codeigniter 脚本,将数据从 mysql 导出到 excel

php - 在 php 中传递不带 ?= 的变量(可能是 .htaccess)

php - htaccess 不适用于 iis

web-services - 大型 "in-house"企业 Web 应用程序是否在 LAN 上通过 SSL 运行?

php - 高级搜索中的 Magento 日期格式