0

So in relation to this post: How to add Valve to Apache Tomcat

I was able to set the Valve inside the server.xml file. (Inside the engine) Now where would I go about placing the rewrite.config file?

I tried to place it inside the WEB-INF of the file, but that only works if I set the valve inside the context.xml, which I don't want to do.

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Mark
  • 49
  • 4
  • 1
    see my answer [here](https://stackoverflow.com/a/49543741/7748072) – Eugène Adell Nov 21 '19 at 10:07
  • Do you want to rewrite URLs only within a single application, or across all applications on the same server (or even for applications that don't exist e.g. `/nosuchapp/index.jsp`? – Christopher Schultz Nov 21 '19 at 15:51
  • I want it across all applications on the same server, and I placed the rewrite here: conf/Catalina/localhost/rewrite.config I added the Valve tag in server.xml, inside , but outside . – Mark Nov 21 '19 at 16:01

1 Answers1

0

Ok so it worked. Thanks to Eugène Adell's post above, and some tinkering.

So I placed the valve inside the the Host tag in the server.xml, so:

<Engine name="Catalina" defaultHost="localhost" jvmRoute="somedomain.com">
  <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="false" deployOnStartup="true">
    <Valve className="org.apache.catalina.valves.rewrite.RewriteValve"/>
  </Host>
</Engine>

Then I placed the rewrite in here:

$CATALINA_BASE/conf/Catalina/localhost/rewrite.config

Mark
  • 49
  • 4