SEO with mod_rewrite

SEO with mod_rewrite

Apache mod_rewrite is one of the most powerful tools I have come across so far in my programming experience. Here is a quick overview of what it can do.

I have spent a marathon session last night in order to learn more about implementing better SEO through utilising incredible and very powerful Apache mod_rewrite module.

This amazing module for Apache web server (which taught me properly why Apache is so talked about and deemed to be the best web server in the world) enables all sorts of wonderful URL tricks to be implemented on a web site.

Typical uses are to re-direct from an old, non-existent directory to a new one (very useful for re-organised sites and for those sites where a lot of content moving takes place), but also for URL re-writing in order to display more search engine friendly URLs.

This is the topic I would like to focus on a little more.

Search Engines prefer crawling pages which look like static HTML pages.

Most bigger systems are dynamic and therefore often feature links with dynamic URLs, including many special characters like $, ?, & and so on, which search engines tend to automatically avoid.

Furthermore, this feature of dynamic web sites tends to confuse search engine crawlers, sending them into an infinite loop sometimes, which is another reason why it is not good to have them, as there is more chance for a web site no to be indexed as well as it could.

This is where mod_rewrite comes into use, through enabling a programmer to quickly re-program the structure of the site through careful use of some regular expressions and the so called rewrite rules which create static like URLs, which are easier for humans to remember also.

Flexewebs CMS now features some interesting mod_rewrite rules which mean that all of our 'end pages' are suffixed with .html extensions and are named in the same manner like an average blog page.

It will be very interesting to observe how Flexewebs CMS becomes indexed from Google and other search engines from now on and to see how our Page Ranks for individual pages end up being.

Another note on mod_rewrite is that it is not easy to 'pick up'.

I easily spent half a night trying to learn some rewrite rules and still have not fully understood how some more advanced implementations are achieved, but the most important tricks are 'in the bag' now.

Most important fact is that mod_rewrite only takes few lines of code in order to implement all these changes which I wrote about, which is nice and elegant solution.

I also noticed that very good resources on mod_rewrite are scarce and difficult to understand and not necessarily very useful, so I might aim to put together some developer resources for those who might want to implement some mod_rewrite rules on their web sites.

Jason Grant

Related items

See also