gpt4 book ai didi

tomcat重写,配置读取但不工作

转载 作者:行者123 更新时间:2023-11-28 22:27:33 28 4
gpt4 key购买 nike

我正在尝试获取 URLlocalhost/article/article-title 来“执行”URLlocalhost/getArticle?文章标题。

我认为我已经正确配置了阀门,因为我在日志中看到了这一点:

03-Apr-2016 01:11:38.206 FINE [Catalina-startStop-1] org.apache.catalina.valves.rewrite.RewriteValve.startInternal Read configuration from /usr/local/apache-tomcat-8.0.33/conf/Catalina/localhost/rewrite.config
03-Apr-2016 01:11:38.208 FINE [Catalina-startStop-1] org.apache.catalina.valves.rewrite.RewriteValve.parse Add rule with pattern ^article/(.*) and substitution getArticle?$1
03-Apr-2016 01:11:38.775 FINE [localhost-startStop-1] org.apache.catalina.valves.rewrite.RewriteValve.startInternal Read configuration from: /WEB-INF/rewrite.config
03-Apr-2016 01:11:38.775 FINE [localhost-startStop-1] org.apache.catalina.valves.rewrite.RewriteValve.parse Add rule with pattern ^article/(.*) and substitution getArticle?$1

我已经在 server.xml 和 context.xml 中激活了它。读取文件 rewrite.config 是因为在日志中,您可以看到:

Add rule with pattern ^article/(.*) and substitution getArticle?$1

这是我的 rewrite.config 的内容:

#To make it work, active the Rewrite Valve is ../META-INF/context.xml 
RewriteRule ^article/(.*) getArticle?$1 [L]

但是当我去 http://localhost/article/article-title ,我在日志中得到了这个:

27.0.0.1 - - [03/Apr/2016:01:12:01 +0200] "GET /article/article-title HTTP/1.1" 404 1036

如何确定重写已激活?

感谢您的宝贵时间。

最佳答案

RewriteRule中要匹配的路径是相对于当前容器的。所以 RewriteRule 应该是:

RewriteRule ^/article-(.*) getArticle?$1 [L]

关于tomcat重写,配置读取但不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36379898/

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