【问题标题】:Redirect to HTTPS except a series of URLs重定向到 HTTPS,除了一系列 URL
【发布时间】:2019-09-15 20:16:05
【问题描述】:

我需要在一系列网址上推迟 https...

现在我得到了这个: https://sub.domain.com/release/download/{id}

我需要将所有 /release/download/{id} url 重定向到 http

我从这里尝试了几种解决方案: Mod_rewrite http->https redirect EXCEPT one URL

但没有任何效果。

我在我的 apache conf 中得到了这个:

RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]

【问题讨论】:

  • IMO 这是一种不好的做法。如果可能,应始终确保连接安全,尤其是当您拥有 HTTPS 证书时。

标签: apache .htaccess https apache2


【解决方案1】:

你可以使用下面的 RewriteRule

RewriteEngine On
#redirect http to https except "/release/download/*
RewriteCond %{REQUEST_URI} !^/release/download/.*
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-13
    • 1970-01-01
    • 2019-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-27
    • 2015-07-20
    相关资源
    最近更新 更多