Get rid of jsessionid parameter in your OfBiz URLs

jessionid, it makes for ugly URLs and can hurt your search rankings. Sure, it’s not technically our problem that the search engines don’t handle them correctly. But since many of us get a good chunk of revenue from the search engines, we get to deal with it. Let me clarify, the site I’m currently working on doesn’t require session tracking to display its informational pages. Besides that, what “normal” user doesn’t have cookies enabled anyway.

At first, I thought I could just enable cookies in ofbiz and that would be the end of it. I was wrong. Try it yourself. Clear your cookies go to an ofbiz page and look at the links on that first page you view. Since search engines don’t utilize cookies, they’re always going to see those jessionid parameters and will see a different one each time they visit your pages (== duplicate content == bad for search results)

If you don’t think it’s a problem, Google currently returns over 41 million results for pages w/jsessionid in the url.

Ok, enough blabbing – here’s how I fixed it. It only takes one rewrite rule to do it:
ReWriteRule ^/(.*);jsessionid=.*$ /$1 [R=301]

Bringing my standard ofbiz rewrite rules up to 5 lines:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*)$1 [R=301]
ReWriteRule ^/(.*);jsessionid=.*$ /$1 [R=301]
RewriteRule ^/$

(FYI – This is for apache 2.x)