gpt4 book ai didi

Tomcat 8.0 重写阀

转载 作者:行者123 更新时间:2023-11-28 21:44:48 25 4
gpt4 key购买 nike

我正在尝试在 Tomcat 8.0 中使用 RewriteValve http://tomcat.apache.org/tomcat-8.0-doc/rewrite.html

在$CATALINA_HOME/conf/server.xml中,我添加了

<Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />

在 Host 标签的正下方

<Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">

$CATALINA_HOME/conf 目录下创建了一个 rewrite.config

RewriteRule ^/abc /myapp

其中 http:/host:port/myapp 是一个工作的网络应用程序。

所以现在当我转到 http://host:port/abc 时,我希望被重定向到 http://host:port/myapp 但我得到取而代之的是 404 请求的资源不可用

它看起来甚至没有读取我的 rewrite.config 文件。 logs 目录中的访问日志仅报告 "GET/abc HTTP/1.1"404 1000,没有更多详细信息。

我错过了什么?谢谢

最佳答案

在 Tomcat 文档中 http://tomcat.apache.org/tomcat-8.0-doc/rewrite.html是写的

The rewrite valve can be configured as a valve added in a Host. See virtual-server documentation for informations how to configure it. It will use a rewrite.config file containing the rewrite directives, it must be placed in the Host configuration folder.

所以尝试将 rewrite.config 移动到 $CATALINA_HOME/conf/Catalina/localhost

小提示:您可以在 rewrite.config 中拼错某些内容(例如 xxRewriteRule ),然后如果 tomcat 读取此文件,它会失败。我认为在你的情况下,即使你拼错了某些东西(因为它没有被阅读),tomcat 也会启动。

关于Tomcat 8.0 重写阀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26932253/

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