Monday, August 29, 2011

Fun with Helicon Ape

Minor inconvenience with someone changing a Sitecore item name (and thus URL) today; this led to stale links from Google, which had not yet re-indexed the new URLs.

Bit of a fail because we should have put a 301 redirect in place to handle this, which leads me on to the reason for this post. Try as I might I couldn't find a simple example for using the IIS7 Helicon Ape plug-in to map the start of a URL/* to a new URL/*, for example: -

i.e. /products/old-category/sub-category/thing/whatever


i.e. /products/new-category/sub-category/thing/whatever

Helicon Ape uses regular expressions to process requests and do the actual redirection at IIS level. Turns out what I needed was to append a $1 (being the first and in this case only parameter to the rewrite expression) to the end of the target URL: -

RewriteRule ^products/old-category/(.*)$$1   [NC,R=301,L]

Job done. Works nicely :)