
Googleing 'Football Shirts'
Google the highly competitive search term ‘Football Shirts’ and consider the result.
The all important first result highlights the search term in all three result return areas – the title, description and URL. To climb to the coveted number one position all too often you’ll need an appropriately keyworded title, description and URL.
Including your most important keywords into your page’s Title and description is easy – just change the <title> and <meta name=”description”> tags however changing the URL structure is an altogether different ball game – especially in ASP.
Fundamentally we want to design a heirarchy of pseudo keyword-rich URLs. When a user browses your website these pseudo URLs are then remapped to real URLs. For example party-packs.co.uk have a product page URL…
http://www.partypacks.co.uk/gold-and-black-celebration-disposable-camera-pid72318.htmlThe likely real URL is something like…
http://www.partypacks.co.uk/part.php?part=72318And so a remapping function could be visualised as…
http://www.partypacks.co.uk/<product-title>-<part-code>.htm …mapped to… http://www.partypacks.co.uk/part.php?part=<part-code>If your webserver runs UNIX this can be performed using the mod_rewrite feature built into APACHE web server. See here for a very easily understood integration article. Here however we’re talking about ASP, so I’ll get more to the point.
The ASP scripting language is hosted on Microsoft’s IIS webserver and has its own URL rewriting engine which, although free, is needlessly complicated and poorly documented/used online. Take my advice and avoid it, look at one of my favourite software tools – HeliconTech ISAPI ReWrite.
ISAPI ReWrite simply emulates APACHE’s mod_rewrite and all its advantages. It’s flexible, fast and very well documented online. If you’re happy to go for the ‘lite’ version (whose only limitation is it can only host one website per webserver) it’s even free! There’s even someone on their support forum called Anton, a hero amongst men that answers all the support tickets within mear hours with straightforward answers. So, to its installation/integration and some examples…
Download the x86/x64 MSI and install it on your webserver. Start the software and select to edit the config file. This is basically a txt file that controls the remapping configuration. Here is where you declare your URL mapping rules.
Taking brightminds.co.uk as an example, they have a generic part page whose real location is the following…
http://www.brightminds.co.uk/showPart.asp?part=A001
…where A001 is the part code of the part being viewed. If A001 were called ‘Soft Dog Toy‘ and found in the keyword-rich category/sub-category heirarchy play-toys/animals then the full desired pseudo URL would be…
http://www.brightminds.co.uk/play-toys/animals/soft-dog-toy.htmImportant – Use hyphens rather than underscores for keyword separation. Underscores are not interpreted correctly by Google.
The mapping function desired would therefore look something like…
http://www.brightminds.co.uk/<category>/<subcategory>/<part-title>.htmSince there’s a generic part page, we can ignore the <category> and <subcategory> for this rewrite rule as they don’t need to be taken into account. Thus what we’re left with is the need to query a database for the <part-code> in response to the <part-title>.
ISAPI ReWrite has no database API so you need to create mapfiles. Mapfiles are simple txt files that map simulated queries so for this example we would need the following mapfile, saved as mapfile.txt…
soft-dog-toy A001 another-description A002
Important – The file needs to be TAB delimited with each line separated by a formal line break.
Now all we need is the mapping rule. Begin the config file with the initialisation and then the rule.
RewriteEngine on RewriteBase / RewriteMap mapfile txt:mapfile.txt RewriteRule ^([^?/]+)/([^?/]+)/(^?/+)\.htm /showPart.asp?part=${mapfile:$3}
Line 3 is fairly self explainatory – declare the mapfile as ‘mapfile’. Subsequent mapfiles can be declared as…
mapfile2 txt:mapfile2.txt
Be aware that by declaring mapfile2.txt you’re doing just that i.e. file declarations, unless otherwise stated are treated as the www root. It is wise to use secure locations such as C:\mapfiles etc, something not accessed by IIS.
Line 4 is where the funky things happen. It’s formatted as the following…
Rewrite Rule <pattern-to-find> <pattern-to-apply> <options>
Each ([^?/]+) means a variable that can be used in the rule. The rule looks at the 3rd variable in the URL pattern (the part title) and via the mapfile finds the part code. The part code is then used in the real URL. Hence, what’s shown as the keyword-rich pseudo URL to users, spiders etc now maps to the real URL.