Wednesday, 29 November 2006

Using Apache's rewrite module to aid Search Engine Optimization

Just recently I have been dabbling with the effects of various Search Engine Optimisation (SEO) techniques and thought I would report on one that I have found particularily effective. I will also attempt to keep this post focussed on the theory, and as such will not contain much related technical information.

The Apache Web Server contains a very useful module called Mod Rewrite, and is one method I use to help the visibility of my sites within Search Engines and I will be using one of my sites as a live example of how this method works.

One of my sites is a Pro Evolution Soccer League and Community site that I created over a year ago. Since then it has had many overhauls, the most recent changes have included the use of the Apache rewrite module.

The site was developed with a PHP back end meaning that a lot of pages had nasty looking URLs, an example of this is the league pages:

/leagues.php?viewLeagueId=546

I have since updated them, with the help of Apache Mod Rewrite, to look like this:
/Leagues/Euro-Leagues/Euro-League-3/546/

Now not only does the new URL look nicer to any user, it also looks good to Search Engines. To prove how this works check out the following google search and you will notice that my site [Backofthenet] is ranked 3rd or 4th from the top for "Euro League".

If you look at the google entry for it you will see it highlights the search terms you used in the URL, approximately half of the URL is in bold meaning it ranked highly for that search. You should try do this for anything you want people to be able to search for.

The general aim is the same for all sites, whether you create static files or use mod rewrite to achieve the same thing, your URLs should always contain keywords related to the page.

Mod rewrite uses regular expressions to invoke rules that you create. You write a condition [using regular expressions] and then a rule. It's similar to and if block, where you only trigger the code inside the if block, if the test passes. I won't get into regular expressions, but here is an example of how your re-write rule should be written:

#www.mysite.com/profilename
RewriteRule ^([A-Za-z0-9-]+)$ /profile.php?viewProfile=$1


The line beginning with # is a comment line, if you have a number of rules you should comment them.
The second line catches all URL requests where letters, dashes and numbers follow the domain like the comment suggests, it then passes that to profile.php as an argument.

You will also notice I use hyphens [dashes] instead of spaces in the URL. If you use spaces in your URLs then any browser viewing the link will encode it into a hexadecimal reprasentationturning any space into %20. This does not look good, and some Search Engines cannot index such links, or at best prefer not to. Most Search Engines interpret a hyphen as a space, so by replacing all spaces in your URL with hyphens you can seperate your keywords without any of the drawbacks of using a space.

To replace spaces with hyphens in your URL you can simply use the following code:
str_replace(" ", "-", $string);

As mentioned at the start there isn't a great deal of technical help here, but here are some links in case you are having problems with the mod rewrite and str_replace.

Tuesday, 28 November 2006

Who is m0nkeymafia?

As this is my first post I thought I would start by giving a small introduction to who I was, and what I do.

My day job is primarily as a C++ programmer for Windows based machines, NT based and CE [Compact Edition - It's a nightmare ask Darren]. As the company I work for hasn't got a comparitvely large software department most people have to do a varying range of jobs from GUI design to algorithm development and optimization. I find my job very interesting and it usually throws up quite a few problems on a day to day basis which is one of the reasons behind this blog. Darren and I often cannot find solutions to problems we have on the Internet, if we find a forum about a problem we are having the poster generally hasn't posted the fix. We intend to document our programming lives with the fixes and results to help other people.

In my spare time I take a great interest in Internet Technologies such as PHP, AJAX, CSS etc. I have a number of, what I like to call "Pet Projects" that I generally use as testing grounds for new technologies. I also work freelance as a Web Developer and Designer and am especially skilled in the design, development and deployment of Content Management Systems (CMS).

Finally I would like to encourage anybody to start discussion or to request an article on a related subject via the Comments section on each post.

Thankyou

Monday, 27 November 2006

Welcome to the home of Systemcoder

We are a couple of software engineers working for a UK company writing software for many different platforms and devices. Currently we do embedded work on several different processors, Windows work on both desktop Windows and Windows CE, a bit of embedded Linux, and recently quite a lot of web based stuff.

We plan on making this blog a series of articles about some of the joys and pains of modern software development. It will include general articles about different bits of technology etc, as well as articles about problems we have come across while developing systems and how we eventually got round them.

It's this section that we see as probably being the most valuable as, as we have tried to solve these problems over time we have often found lots of other people on the net with the same problems and no one with the answers, so we hope this will become a repository of annoying little problems and there solutions, as well as a rich collection of other software engineering tips and tricks.