mapping welcome file to prettified url
December 5, 2011 at 7:10 pm #18116
I have a requirement that I cannot seem to figure out how to fullfil.
The project is configured to have welcome file as index.xhtml
Faces servlet mapping and the default suffix are configured for *.xhtml
We are on Tomcat 7 and servlet 3.0 with mojarra 2.1.4
We have a url mapping of pattern “/” to view-id “/index.xhtml”
What I want is, if a visitor tries to access mydomain/myapp/index.xhtml, I want the visible url to be changed as mydomain/myapp/ or mydomain/myapp
To accomplish this, we used to have a rewrite rule to match “index.xhtml” to substitute “/” when we were on 3.3.0
We upgraded to 3.3.2 and it no longer works
Does anyone have any idea about what I can do?December 7, 2011 at 7:27 am #21799
I read somewhere that 3.3.2 improves on 3.3.0 to eliminate some cases that end up in infinite loops. Perhaps that explains the behaviour change there.
Anyway, my question actually boils down to this:
I would like mydomain/myapp/index.xhtml to redirect to mydomain/myapp/ (the trailing slash is not important here for me, as long as it is consistent) while index.xhtml is also the welcome file.
Is there a way I can accomplish this?December 7, 2011 at 5:10 pm #21800
Lincoln Baxter IIIKeymaster
Could you please post your existing code when reporting issues like this? It helps us to understand what you are doing and see what might actually be wrong; hard to know what’s wrong otherwise.
It should still be possible to do this. Not exactly sure what would have changed.
Post your relevant lines of config and we’ll see what’s happening.
~LincolnDecember 14, 2011 at 11:31 am #21801
Thanks for your interest. Please forget about any “issue” that I described. What I actually want to know is this:
is there a way to make sure when a visitor directly accesses the welcome file “index.xhtml”, he is redirected to “/”
What I’m trying to accomplish is to avoid:
to both get into the google index. In fact, I don’t want anyone to know about index.xhtml.
Can I somehow use prettyfaces for this purpose?
SerkanDecember 14, 2011 at 5:35 pm #21802
In theory this should be possible with a rewrite rule like this:
<rewrite match="/index.xhtml" substitute="/" redirect="301"/>
However there is currently a bug in PrettyFaces 3.3.2 that prevents this from working correctly. I’m currently working on fixing this. I’ll come back to you as soon as I committed the fix to the snapshots.December 15, 2011 at 8:13 am #21803
Actually <rewrite match=”/index.xhtml” substitute=”/” redirect=”301″/> used to work in 3.3.0 and in 3.3.2 it causes an infinite redirect loop.
Since you’re going to be committing the fix to this in the snapshots, I need to ask this:
Are the snapshots safe to use in a production environment?
SerkanDecember 15, 2011 at 3:13 pm #21804
Yeah, I know that it worked in 3.3.0. But the fact that it worked was actually a side-effect of some other bug that we fixed in 3.3.2!
I think it’s very safe to use the snapshots of the 3.x branch because there is currently no active development done on 3.x. We are currently focusing on 4.x and 3.x is a “bugfix-only” branch!
ChristianDecember 15, 2011 at 4:35 pm #21805
Thanks. What is the version for the v3 snapshot? I can’t figure out what to write in pom.xml
SerkanDecember 15, 2011 at 4:50 pm #21806December 16, 2011 at 5:20 am #21807
I just committed the fix and pushed it upstream. Could you give 3.3.3-SNAPSHOT a try?
This should work now with:
<rewrite match="/index.xhtml" substitute="/" redirect="301"/>December 16, 2011 at 8:41 am #21808
I just tested it and it works like a charm.
Thank you very much.
Looking forward to the release of version 4December 16, 2011 at 10:29 am #21809
Great! Thanks for testing! I think we will release 3.3.3 in a few weeks.
You must be logged in to reply to this topic.