1

I'm trying to have the URL localhost/article/article-title to "execute" the URL localhost/getArticle?article-title.

I think I've configured my valve right, because I see this in the log :

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

I've actived it on the server.xml and in the context.xml. The file rewrite.config is read because in the log, you can see this :

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

This is the content of my rewrite.config :

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

But when I go to http://localhost/article/article-title, I got this in the log :

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

How can I be sure the Rewriting is activated ?

Thanks for your time.

kowalsky
  • 11
  • 1
  • 2

1 Answers1

0

The path to be matches in the RewriteRule is relative to the current container. So the RewriteRule should read:

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