djmj
djmj

Reputation: 5544

JSF OCPSoft automatically redirect request of unwritten URL to rewritten one

we are using OCPSoft Rewrite library to create pretty rewritten URLs. This works great and as expected but we now want to redirect the original unwritten URL to its rewritten since the same resource can be accesses by the original and the rewritten URL.

In some cases this can lead to duplicate content URLs for SEO. We counter this with canonical meta tag but a permanent redirect is better and more generic.

Example mappings

  1. Original URI: /index.xhtml rewritten to: /
  2. Original URI: /index.xhtml?category=Foo rewritten to: /c/Foo.
  3. Original URI: /index.xhtml?category=Foo&bar=abc&test=123 rewritten to: /c/Foo?bar=abc&test=123.

Intended behavior

Entering the original URI in browser a permanent redirect to the rewritten URL should happen with support for mapped and unmapped query params.

Workaround

With a Faces Filter we could generate the bookmarkable "rewritten" URI in code by redundantently adding "reverse" rules to perform a 301 permanent redirect.

Is it possible to do this with the OCPSoft Rewrite library automatically?

Upvotes: 1

Views: 51

Answers (0)

Related Questions