gpt4 book ai didi

apache - 在 Apache 2.4 中链接 URL 重写规则

转载 作者:行者123 更新时间:2023-11-28 23:28:07 29 4
gpt4 key购买 nike

需要一些帮助在 apache v2.4 中编写重写规则。

我有一个 web 应用程序托管在 tomcat v8.0.29 中,它有这个 url:

http://myapptest:8080/app

通过 mod_jk 和 apache 重写引擎的魔力,我已经能够将其清理到 http://myapptest。 .

我现在在 apache 中配置了 SSL,我需要 http://myapptesthttps://myapptest被重定向到 https://myapptest.domain.com .

在 httpd-ssl.conf 中,我有这个处理重写内容的虚拟主机配置:

<VirtualHost _default_:443>
ServerName myapptest
RewriteEngine on
RewriteRule ^/$ /app [NC,PT,L]
DocumentRoot "c:/apache/tomcat/webapps/app"
JkMount /* myapp
ErrorLog "logs/myapptest-error.log"
CustomLog "logs/myapptest-access.log" common
...other stuff...
</VirtualHost>

然后,在 httpd-vhosts.conf 中,我处理端口 80 上的 http 流量的重定向。

<VirtualHost myapptest:80> 
ServerName myapptest
Redirect / https://myapptest.domain.com/
</VirtualHost>

我遗漏的最后一部分是如何处理 https://myapptest 的重定向?

如果有更好、更简洁的方法来处理这个问题,我非常乐意接受,因为我不是这方面的专家。

最佳答案

避免在 VirtualHost 标签内使用主机名:

# First listed is the default for port 80
<VirtualHost *:80>
ServerName myapptest.domain.com
</VirtualHost>

# Capture the short hostname and redirect to FQDN
<VirtualHost *:80>
ServerName myapptest
Redirect / https://myapptest.domain.com/
</VirtualHost>

关于apache - 在 Apache 2.4 中链接 URL 重写规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34361074/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com