apache - 是否可以将我网站的特定页面(使用 https)重定向到 http?

标签 apache .htaccess http mod-rewrite url-rewriting

瞄准

我想将我网站的特定页面重定向到 http。

背景

我有以下.htacess

Options All -Indexes
RewriteEngine On 
RewriteRule ^(.*)\.html $1\.php [L]
RedirectMatch ^/*$  https://**mydomain_name**/files/index.php   
Options +SymLinksIfOwnerMatch 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /files/error.php [L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

它允许我将所有内容重定向到 https(而且效果很好)

问题

是否可以将地址包含 internal (https://mydomain_name/internal/) 的所有页面重定向到 http(而不是 https)?

最佳答案

更好的是,我们可以保持条件不处理对包含 internal 的 URI 的请求,而不是先将它们重定向到 https,然后再返回到 http 以获得特别提到的 URI。

Options All -Indexes
RewriteEngine On 
RewriteRule ^(.*)\.html $1\.php [L]
RedirectMatch ^/*$  https://**mydomain_name**/files/index.php   
Options +SymLinksIfOwnerMatch 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /files/error.php [L]
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/internal [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

关于apache - 是否可以将我网站的特定页面(使用 https)重定向到 http?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65369564/

相关文章:

apache - 对于不存在的文件,将所有请求转发到一个 index.php 文件,但“包括”index.php 本身

java - Apache cxf 服务器异步请求处理

apache - 如何使用xampp VM创建虚拟主机?

PHP get_headers 不适用于本地 Apache URL

php - 使用 mod_rewrite 使博客 URL 更加 SEO 友好

php - 删除文件扩展名 htaccess 不起作用

.htaccess - 在 htaccess 中重写 URL 时添加 .html?

javascript - Node api 不向客户端 ajax 请求返回数据

javascript - 提供 JavaScript 文件时,使用 application/javascript 还是 application/x-javascript 更好

php - 当端口始终为 80 时重定向 HTTP > HTTPS