繁体   English   中英

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

[英]Redirect One Page to http instead of https

我有我的 .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]

你可以在相同数量的行中做到这一点:

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

如果没问题,请将R更改为R=301以获得永久重定向,因为单独的R将被视为R=302和临时重定向。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM