[solved] url rewrite removing the ;jsessionid= from the url
June 30, 2010 at 8:09 am #17748
Hi, first of all i would like to say that PF has saved a lot of time and made the jsf rewriting a painless issue (almost ) for us !
We have a problem here that is bothering us,
we are trying to use the following thing
<rewrite match=”^/foo/(.*)$” substitute=”/bar/$1″ />
we are trying to rewrite it so that it will remove the whole “;jsession=….” part from the url.
Could any one help with the regex or tell us how to do it?
We have only managed to remove the “;jsessionid” part but not more:/
Thanks for your time,
DimmanJune 30, 2010 at 3:46 pm #19972
Try this rule to remove JSessionID from inbound URLs – it has not been verified on outbound URLs, but please let us know if you get it to work, or if you can’t, what’s holding you back:
<rewrite match="(?i)^(.*);jsessionid=w+(.*)" substitute="$1$2" redirect="301"/>June 30, 2010 at 5:28 pm #19973
Thanks for your reply.
I could not make it work however if i removed the = from the jsessionid then it worked (for url’s without = after the jsessionid)!June 30, 2010 at 5:29 pm #19974
Could you post your solution?
Could you also post the Before & After URLs? Before rewriting, and after rewriting?
This will help me figure out what to do Thanks!June 30, 2010 at 6:24 pm #19975
Well this is before and after! here are some of the cases:
The site can be seen at www aggeliofrenia gr.
I dont know what i’m doing wrong. I’m not an regex expert! But maybe there is
something specifc about this jsessionid=.
(although i red that it can be done with rewriting).
Thanks again for your timeJune 30, 2010 at 6:46 pm #19976
you might as well simply disable appending of the jsessionidJune 30, 2010 at 7:04 pm #19977
we dont have support for Servlet 3.0, tried thatJune 30, 2010 at 8:42 pm #19978
So, enabling this functionality in PrettyFaces actually requires a modification to be made. The JSessionID will always be appended in the URL because the prettyfaces rewritten URL is passed to the container after the rewrite occurs. This means that jsessionid is appended after rewrite rules are processed.
See related source code in PrettyFacesWrappedResponse
In effect, you can remove JSessionID from inbound URLs, but with the current configuration, not from links. I’ve been debating this functionality, but it would add a level of complexity that I’m not sure is a good thing.
Opinions welcome.June 30, 2010 at 10:43 pm #19979
Well, i think that it would be a nice feature! Its all about seo, and making things easier. But i agree that it would make things a bit more complexAugust 18, 2010 at 1:12 pm #19980
Previously I have configured a sun-web.xml for my case:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD GlassFish Application Server 3.0 Servlet 3.0//EN"
<!-- Don't add JSESSIONID for resources -->
<property name="enableURLRewriting" value="false"/>
But now I’m going for domdorn’s suggestion.August 20, 2010 at 5:13 am #19981
I looked in to this deeper, and it seems like removing this functionality in PrettyFaces would probably be bad practice.. it’s possible, but not really a great thing to do since it breaks some assumptions that the server makes in order to host websites properly.September 11, 2010 at 6:20 pm #19982
Rewrite rules should now apply with the latest prettyfaces version, and this should also work via prettyfaces now.
This will remove JSESSIONID from *inbound* requests:
<rewrite match="(?i)^(.*);jsessionid=w+(.*)" substitute="$1$2" redirect="301"/>
Outbound requests will still contain the value until how to properly handle this is determined.
You must be logged in to reply to this topic.