[英]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.