Search code examples
urljsffaceletsjava-ee-6web.xml

Hide website filenames in URL


I would like to hide the webpage name in the url and only display either the domain name or parts of it.

For example:

I have a website called "MyWebSite". The url is: localhost:8080/mywebsite/welcome.xhtml. I would like to display only the "localhost:8080/mywebsite/".

However if the page is at, for example, localhost:8080/mywebsite/restricted/restricted.xhtml then I would like to display localhost:8080/mywebsite/restricted/.

I believe this can be done in the web.xml file.


Solution

  • I believe that you want URL rewriting. Check out this link: http://en.wikipedia.org/wiki/Rewrite_engine - there are many approaches to URL rewriting, you need to decide what is appropriate for you. Some of the approaches do make use of the web.config file.