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

#23590

Stephan Rudolph
Participant
package ch.rudolphag.config;

import org.ocpsoft.rewrite.config.Configuration;
import org.ocpsoft.rewrite.config.ConfigurationBuilder;
import org.ocpsoft.rewrite.el.El;
import org.ocpsoft.rewrite.servlet.config.HttpConfigurationProvider;
import org.ocpsoft.rewrite.servlet.config.rule.Join;
import javax.servlet.ServletContext;

/**
 * Created by Stephan Rudolph rudolph ag.
 * Date: 24.03.13
 * Time: 12:45
 *
 * @author: Stephan Rudolph
 */
public class RewriteConfigurationProvider extends HttpConfigurationProvider {

    @Override
    public int priority() {
        return 10;
    }

    @Override
    public Configuration getConfiguration(final ServletContext context) {
        return ConfigurationBuilder.begin()
            .addRule(Join.path("/").to("/pages/index.xhtml"))
            .addRule(Join.path("/{lang}/{path}")
                .where("lang").bindsTo(El.property("localeHandler.languageSelected"))
                .where("path").matches(".*")
                .to("/pages/{path}"))

            ;
    }
}