Reply To: SEO URL supporting l10n/i18n with //Rewrite

Splash Forums Rewrite Users SEO URL supporting l10n/i18n with //Rewrite Reply To: SEO URL supporting l10n/i18n with //Rewrite

#23606

Stephan Rudolph
Participant

Hello Christian

thank you very much for your hint regarding `PhaseBinding`.

By implementing your proposal, we got rid of both, the exception:

org.ocpsoft.rewrite.exception.RewriteException
	...
Caused by: java.lang.IllegalArgumentException
	...

as well as the exception:

	
org.ocpsoft.rewrite.exception.RewriteException
	...
Caused by: javax.el.PropertyNotFoundException

Now, our code looks like this:

@Override
public Configuration getConfiguration(final ServletContext context) {
    return ConfigurationBuilder.begin()
        // 1. Case: Request from outside without LOCALE, PATH and VIEW information (homepage)
        .addRule(Join.path("/")
            .to("/pages/index.xhtml"))
        // 2. Case: Request from outside with LOCALE, VIEW or PATH and VIEW information (bookmark)
        .addRule(Join.path("/{lang}/{path}")
            .to("/pages/{path}")
            .where("lang").bindsTo(PhaseBinding.to(El.property("localeHandler.languageSelected")))
            .where("path").matches(".*"))
        // 3. Case: Request from internal (navigation)
        // TBD
        ;
}

The statement that should handle the 2nd case (see above) does nothing. The shape of the URL remains the same than without applying the rewrite statement. Instead, applying the rewrite statement, resources (images, etc.) become not reachable because they become an `.xhtml` attached, resulting in an exception like this:

com.sun.faces.context.FacesFileNotFoundException: /pages/solutions_weblogic_platform_lifetime_en.png.xhtml Not Found in ExternalContext as a Resource

How has the rewrite statement for the 2nd case to be, in order to achieve the behavior as described above?

What rewrite statement does we need to address the 3rd case as described above?

Best regards Stephan