1

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?

Community
  • 1
  • 1
internet
  • 385
  • 1
  • 8
  • 27
  • No websites have been seen so far that use this sort of URLs. Why not use REST like things instead in which you can meet with URLs such as those you see on this site (stackoverflow.com including other sites in its network)? – Tiny Dec 23 '14 at 14:53
  • 1
    @Tiny: never seen https://zeef.com? It uses basically the same technique, albeit for a completely different functional requirement. – BalusC Dec 23 '14 at 17:51
  • @BalusC : I visited several times but did not (much) concentrate on the incoming URLs in the address bar. :) – Tiny Dec 23 '14 at 18:00

1 Answers1

1

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}"))
Lincoln
  • 3,151
  • 17
  • 22
  • Hi Lincoln, thank you - and where are the parameter are coming from? {username} ? What do you mean with {suffix} and what is {loggedInUser}? Which kind of code you I need in the JSF page and in one of my beans? – internet Jan 08 '18 at 09:00
  • Hi. The parameters are created using Rewrite parameterization: https://github.com/ocpsoft/rewrite/blob/master/documentation/src/main/asciidoc/configuration/parameters.asciidoc – Lincoln Jan 09 '18 at 19:18
  • To add integration with JSF, you need to add the respective Rewrite extension: https://github.com/ocpsoft/rewrite/blob/master/documentation/src/main/asciidoc/integration/cdi.asciidoc – Lincoln Jan 09 '18 at 19:18