The Kat's Work - Blog
Main | Blog | Registration | Login
2:53 AM
Welcome Guest | RSS
Main » 2010 » December » 23

URL abstraction beloved by google, and hated by developers. If you have more than a passing knowledge of SEO you will "Know” that google (and others search engines.) loves abstracted urls. For good reason abstracted urls show google that even if you change the technology driving a website the urls will remain valid. In general the spectrum of urls go.

Worst - /bfb3d0325166a504802577de005cd97e/8ed70bc2c19e68f7802577de00601b62?OpenDocument

Best (or at least better)

However these abstracted urls (e.g. are quite difficult to implement in dynamic websites where one "masterpage” may be used to create a large number of different webpages.

A colleague recently pulled this off in a application quite easily. So I became determined to find away to do this in Java, specifically Java Spring. This is were a rather wonderful product called Url Rewrite Filter. This magnificent piece of script allows you to create a filter in your java application that will forward an abstracted url to a url your app will understand.

There are several setups, here I will describe how to create seamless abstraction. For example your users requests and your application responds with the content for without the user(and the googlebots.) being aware of any shenanigans.

First off go and download from . Once downloaded extract into your web-inf this will place an xml file called urlrewrite into your webinf and add the required jars into your lib.

Next add the following to web xml.


this will create a filter that will forward all url requests to be processed by the urlrewriter. As you can see this default filter has all requests (/*) being subject to the urlRewriterFilter. I would suggest leaving this as it is the urlrewriter.xml allows for a lot of control.

Next we need to set some rules. In the urlrewriter.xml file we already have some examples very kindly supplied by the developer. The first to do with a rule is to set the from. In version 3.2 we can use regular expression (arrrrrrggggghhhh!!) or much nicer wildcards (i.e /test/*/). I’d choose wildcards but have a good look at the symantics of the wildcards in the manual.

Once you have a rule with a from you need to let the url rewrite filter code now what form the url should take. To do this we set the to of the rule. In the "to” we refer to the wildcarded/regex from the from as $<occurance> (i.e. in /test/*/*/ the text of the first wildcard is referenced as $1). Below is a working rule.

<rule match-type="wildcard">

The rule above would take the url which your app would not understand and silently convert it to

There you go using this you can easily abstract your urls……but wait there’s more reading into the manual urlrewriter allows for lots of advanced options I can see another blog coming.

Remember there is a manual located at here.
Views: 10488 | Added by: The_Kat | Date: 2010-12-23 | Comments (3)

Login form
«  December 2010  »
Entries archive
Site friends
  • Create your own site
  • My Blog
  • Statistics

    Total online: 1
    Guests: 1
    Users: 0
    Copyright MyCorp © 2019
    Website builderuCoz