tags:

views:

58

answers:

2

Good evening all.

Is there a standard way to do the redirection/rewrite of a specific url to a different one?

Imagine an user accessing the following view: http://www.something.com/us/download.xhtml?id=2

I want to set the Locale from the previous view and redirecting to http://www.something.com/download.xhtml?id=2

<page view-id="/us/download.xhtml*" action="<action to set the locale>"> <navigation> <redirect view-id="#{facesContext.viewRoot.viewId}" /> </navigation> </page>

Well, basically, i want to set the locale (example: us), passed on the viewId /us/download.xhtml and redirect to viewId without locale reference.

Thanks

A: 

Use a Filter listening on /* which extracts the locale from the URL and forwards the request to the new URL without locale prefix. You should really not redirect, the URL with the locale will get lost and this is very bad for SEO, because you would then provide multiple contents behind one same GET URL while GET is supposed to be idempotent. It would also make the localized page unbookmarkable. Just forward the request.

BalusC
A: 

You should consider using PrettyFaces URL-rewriting, they have a <rewrite match="oldurl" substitute="newurl" /> feature that will allow you to accomplish this, in addition to mapping pretty urls such as /login to replace standard urls such as /faces/login.jsf.

<url-mapping id="store"> <pattern value="/store/" /> <view-id>/faces/shop/store.jsf</view-id> </url-mapping>

Docs for the rewrite feature: Reference Guide

Lincoln