如何在没有mod_rewrite的情况下重定向除一个路径及其所有子路径之外的所有URL?

wat*_*ery 4 regex redirect apache2.4

我在Tomcat 7前面有Apache 2.4(尽管我认为前者在这里很重要).我需要将域上的所有请求重定向到HTTPS端口,但不是那些转到特定文件夹的请求:

(1) http://www.example.com/ -> https://www.example.com/
(2) http://www.example.com/products -> https://www.example.com/products
(3) http://www.example.com/... -> https://www.example.com/...
Run Code Online (Sandbox Code Playgroud)

(4) http://www.example.com/services should pass straight 
(5) http://www.example.com/services/main should pass straight
(6) http://www.example.com/services/main/list?params should pass straight
Run Code Online (Sandbox Code Playgroud)

如何在不使用的情况下完成此操作mod_rewrite(正如我在其他问题中发现的那样)?

我在文档中看到重定向是使用RedirectRedirectMatch指令处理的.

所以我可以处理1,2,3:

<VirtualHost *:80>
    ...
    ServerName www.example.com
    Redirect / https://www.example.com
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

但我不能写一个正则表达式来处理其他三个.我在这个答案中发现我可以使用负面的外观,但正则表达式/(?!services).*只会匹配4(至少根据Regex Tester

编辑

我已经明确指出,这可以在没有的情况下完成mod_rewrite.

anu*_*ava 6

在此处使用基于正则表达式的重定向规则:

<VirtualHost *:80>
    ...
    ServerName www.example.com
    RedirectMatch 301 ^/((?!services).*)$ https://www.example.com/$1
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

(?!services) 是一个负向前瞻,除了开头的URL之外的任何URL /services