.htaccess - 使用 htaccess 从特定文件夹中删除 SSL 集成

标签 .htaccess ssl

我的整个站点都集成了 SSL,并放置了 htaccess 代码,以便在任何人访问我的域 URL 时重定向到 https。但我想将一个文件夹保留在重定向到 https 之外。请帮助我...下面是放置在我根目录中的 htaccess 代码,用于将所有请求重定向到 https 副本

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

谢谢

最佳答案

只需添加一个排除文件夹的条件:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/folder1
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

如果您想将 /folder1 的 SSL 请求重定向到非 SSL,则:

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/folder1
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

关于.htaccess - 使用 htaccess 从特定文件夹中删除 SSL 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17539114/

相关文章:

php - .htaccess - 子目录不起作用

wordpress 利用浏览器缓存

java - Android SSL 问题

ios - 使用 Microsoft Azure SDK 在 iOS 中固定 SSL 证书

.htaccess - 如何使 .htaccess 在当前目录而不是子目录上工作?

php - Godaddy Ubuntu 3.6 mod_rewrite 问题

.htaccess - 将整个站点重定向到子文件夹

node.js - 使用 OpenSSL 支持编译 Node.js

java - 如何调试对 https URL 的 cfhttp 调用

ssl - cPanel 的 AutoSSL 限制