Search code examples
http-redirectjbosswildflyhttp-status-code-301undertow

Wildfly 15 Undertow permanent redirect


I created a undertow-handlers.conf in my WEB-INF folder.

I added a bunch of rows like this:

regex('/foo') -> redirect('/bar');

That works as expected, redirecting all requests of /foo to /bar.

Unfortunately, the response code is 302 (moved temporarily).

I need it to respond with 301 (moved permanently).

I can't manage how to do that. Any ideas?


Solution

  • I found the solution by myself:

    regex('/foo') -> { set(attribute='%{o,Location}', value='/bar'); response-code(301); }