重定向到HTTPS(一系列URL除外)

时间:2019-04-26 10:20:26

标签: apache .htaccess https apache2

我需要将https放到一系列网址上...

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

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

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

但没有一个。

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

dateval     types   freq
2019-04-01  rock    1
2019-04-02  rock    2
2019-04-03          0
2019-04-04  rock    1

1 个答案:

答案 0 :(得分:0)

您可以使用以下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]