簡體   English   中英

如何在.htaccess中強制使用單個頁面的HTTP而不是https

[英]How to force http of a single page instead of https in .htaccess

我使用.htaccess中的此代碼強制在網站的所有頁面上使用https

RewriteEngine on  
RewriteCond %{HTTPS} !=on  
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

但是我有一個我不希望使用https的頁面videos.php,我希望它是普通的http,我該怎么做? 有人可以幫忙嗎?

嘗試將.htaccess更改為

RewriteEngine on
RewriteRule ^videos.php - [L,NC]
RewriteCond %{HTTPS} !=on  
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

這將檢查以videos.php結尾的網址,並且不會對這些網址做任何事情。

您可以具有如下規則:

RewriteEngine on

# force HTTPS for all pages except videos.php
RewriteCond %{HTTPS} off
RewriteRule !^videos\.php$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]

# force HTTP for all pages except videos.php
RewriteCond %{HTTPS} on
RewriteRule ^videos\.php$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM