Reply To: 301 Redirect using OCPsoft Rewrite

Splash Forums Rewrite Users 301 Redirect using OCPsoft Rewrite Reply To: 301 Redirect using OCPsoft Rewrite

#26844

It is not that complicated. My personal opinion on that is just that the app server shouldn’t bother which host name is used. IMHO that is up to the reverse proxy which is usually a httpd. So if you already have an httpd as a reverse proxy, it is usually easier to configure something like that there.

However, if you want to implement this requirement with Rewrite, you could try something like this:

.addRule()
.when( Direction.isInbound().and( 
    Domain.matches( "www.old-domain.com" ).and( 
    Path.matches( "{path}" ) ) ) )
.perform( Redirect.permanent( "http://www.new-domain.com/{path}" ) )
.where( "path" ).matches( ".*" )

I didn’t test it but it should be a good start.