In the latest part of the series, I am going to explain one of the technologies we will use to build the SEO CMS. In this article I am going to be providing you with a sample .htaccess below, as well as explain what is it will do.
Firstly I am going to explain what a .htaccess file is. A .htaccess file is a configuration override file which has recursive properties, with those overrides being overridden with a .htaccess file in a subfolder of the main .htaccess file. Don’t worry if you do not understand this as you will learn these facts over time, or alternatively you can contact us to help you with any .htaccess issues you may be having.
Sample configuration:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com
rewriterule (.*) http://www.example.com/$1 [R=301,L]
RewriteRule ^([A-Za-z0-9-]+)/$ index.php?page=$1
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+).html$ index.php?page=$1
So what are those 5 lines which are key to your website actually doing? Well I am going to be splitting this down into two sections, the first two lines and the second set of two lines.
Line 1:
RewriteEngine On. This enables the apache mod_rewrite option which allows us to send a URL to apache, and have apache process the data and come out with what would be the real URL which would be expected.
Canonicalization fix
The First two lines are a fix for the common URL canonicalisation problem of http://example.com not redirecting correctly. This line is effectively pushing all traffic which maches the domain to the www. version, whilst employing the correct 301 redirect.
Mod_rewrite
The next two lines are the bit that ensures you do not have to output a querystring. what they are doing is allowing your web browser to input a URL in the format http://www.example.com/reddwarf/ and translate it into http://www.example.com/index.php?page=reddwarf. With this input you now have the control to check for database rows which correspond to this and provide all of hte data as you would normally expect.

