Ocpsoft Rewrite JSF subdomain

442 Views Asked by At

I want to create the following scenario:

1. Step:

Login page: The user will login into the web portal. Each user has an username. For example tester12345. This username is stored in the database.

2. Step:

After the redirect from the login page, all pages should be in this format:

http://tester12345.domain.com/..

This means: {username}.domain.com/..

How can I do this?

1

There are 1 best solutions below

3
Lincoln On

You would need to do something like this:

.addRule(Join.path("/").to("/internal_resource_blah.jsp"))
.when(Direction.isInbound()
   .and(Domain.matches("username")
   .and(***username is in database***)))
.otherwise(SendError.code(404, "Page not found or some error."))

.addRule()
.when(Direction.isOutbound()
   .andNot(URL.matches("http://{username}.domain.com{suffix}"))
   .and(***user is logged in***))
.perform(Substitution.with("http://{loggedInUser}.domain.com{suffix}"))