我在 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/...
尽管
(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
我怎样才能在不使用的情况下做到这一点mod_rewrite
(正如我在其他问题中所说的那样)?
我在文档中看到重定向是使用Redirect和RedirectMatch指令处理的。
所以我可以处理 1,2,3:
<VirtualHost *:80>
...
ServerName www.example.com
Redirect / https://www.example.com
</VirtualHost>
但我无法编写正则表达式来处理其他三个。我在这个答案中发现我可以使用否定的环视,但是像这样的正则表达式/(?!services).*
只会匹配 4(至少根据Regex Tester on
编辑
我已经指定这可以在没有mod_rewrite
.