I'm using pretty faces 3.4.4. I want to redirect pages with following url:
www.domain.com/overview/overview.xhtml?target=my_param
to
www.domain.com/my_param
To achieve this I use this setting:
<url-mapping id="overview">
<pattern value="/#{target}" />
<view-id value="/overview/overview.xhtml"/>
</url-mapping>
which is working. But the issue is, that all the standard pages in root like aboutus
, home
and contact
are not working any more! The content of this pages is overwritten with the content of the my_param
page.
Can any one help to fix this? Thanks
You'll likely need to change the order of your rules in the <pretty-config>
file. They are matched in order, and the issue here is that your mapping pattern is very general, and will match ALL possible pages at the top level of your domain:
<pattern value="/#{target}" />
To fix this, you need to add mappings for your other top-level pages, and they need to be above your general rule for handling "my_param" redirects:
<url-mapping id="home">
<pattern value="/home" />
<view-id value="/home/home.xhtml"/>
</url-mapping>
<url-mapping id="contact">
<pattern value="/contact" />
<view-id value="/contact/contact.xhtml"/>
</url-mapping>
<url-mapping id="overview">
<pattern value="/#{target}" />
<view-id value="/overview/overview.xhtml"/>
</url-mapping>
You haven't posted how you are issuing the redirect, which you said is working, but if you wanted to do that using PrettyFaces, you'd use something like this config:
<rewrite match="/overview/overview.xhtml?.*\btarget=(\w+)\b" substitute="/$1/" redirect="301" />
Though I would probably use OCPsoft Rewrite for this type of redirect instead, since you can make much more declarative & safe rules. (PrettyFaces is now built on Rewrite)