【问题标题】:How to exclude folders from HTTPS redirects with .htaccess如何使用 .htaccess 从 HTTPS 重定向中排除文件夹
【发布时间】:2017-03-11 02:42:05
【问题描述】:

我正在尝试将 HTTP 请求重定向到 HTTPS,但我不需要重定向所有内容,我想排除一些文件夹(如 bower_components folder)以避免加载两倍的 javascript 和 css 内容。

我在 .htaccess 上使用的代码是:

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

如何更新 .htaccess 以排除重定向中的文件夹?

【问题讨论】:

标签: .htaccess http redirect https


【解决方案1】:

添加更多 RewriteCond 指令以过滤您不想重定向的路径。例如

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 2014-03-16
    • 2021-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多