tomcat - Apache Tomcat 9 重写阀不起作用
问题描述
我一直在尝试设置我的 tomcat 9 重写阀(在全局级别)但没有成功,按照我在互联网上找到的每个教程进行操作,但无论我如何配置我的 rewirte.config,阀都无法正常工作。
所以我写了我能想到的最简单的rewrite.config,它只包含一行:
RewriteRule ^test$ manager/test.jpg
所以这条规则只是意味着将http://localhost:8080/test重写为http://localhost:8080/manager/test.jpg
这个文件放在 $CATALINA_HOME/conf/Catalina/localhost 我已经在 localhost.2018-08-30.log 日志文件中验证了阀门已正确加载:
30-Aug-2018 14:32:43.530 FINE [main] org.apache.catalina.valves.rewrite.RewriteValve.parse Add rule with pattern ^test$ and substitution manager/test.jpg
但是,当我重新启动 tomcat 并对其进行测试时,URL http://localhost:8080/test给了我一个 404 错误,而 URL http://localhost:8080/manager/test.jpg正确加载了实际图像。
访问日志显示:
127.0.0.1 - - [30/Aug/2018:14:39:50 +0800] "GET /test HTTP/1.1" 404 1078
127.0.0.1 - - [30/Aug/2018:14:42:34 +0800] "GET /manager/test.jpg HTTP/1.1" 304 -
那么我错过了什么?
解决方案
推荐阅读
- python - TypeError:预期的二进制或 unicode 字符串,得到 618.0
- racket - 代表管道的函数列表的类型化 Racket 类型
- ionic-framework - Ionic 自动向特定联系人发送 WhatsApp 消息
- javascript - 无法使用cordova在android上播放视频
- android - 如何将单个 webView 用于片段中的多个按钮
- c++ - GCC 的 C++17 内联静态成员类变量错误
- javascript - 如何显示图像并嵌入到脚本文件中?
- javascript - 使用 Firebase 函数创建另一个文档时如何更新文档中的数据?
- javascript - 在不发送/api/register 响应的情况下解决任何 API 解决方案,这可能会导致请求停止。?
- php - 在登录表单中使用密码验证时不起作用