如何将HTTP重定向到https而在Apache中不加斜杠?

时间:2019-06-27 14:20:35

标签: apache server web-config ubuntu-16.04 configserver

我想将网址从http重定向到https,但是如果该网址没有Traillin斜杠,则不会被重定向。我尝试过很多方法,因为我在Apache中还算不错,但是我还没有做到。 这是配置:

<VirtualHost *:80>
    ServerName mydomain.nl
    ServerAlias www.mydomain.nl
    ProxyPass / http://127.0.0.1:3001/
    ProxyPassReverse /  http:127.0.0.1:3001/
    ProxyPreserveHost On
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    Redirect permanent / https://mydomain.nl
</VirtualHost>

1 个答案:

答案 0 :(得分:0)

您可以使用ProxyPassMatch指令代替ProxyPass。它允许使用正则表达式匹配网址。例如:

ProxyPass (^.*[^\/]?$) http://127.0.0.1:3001/

如果该网址不包含任何字符或包含字符且不以“ /”结尾,则该网址应匹配