Using a Content Management System for Search Engine Positioning - How to Tweak an Out-of-the-Box CMS to Help in Search Engine Rankings
(Page 2 of 4 )
To tweak a CMS to help your search engine rankings, first we have to look at the issue of dynamic URLs. Most CMSs will generate URLs with parameters embedded into them. Each article on your site may look like this:
http://yoursite.com/modules.PHP?op=modload&name=News&file=article&sid=35&SESSIONID=
200dbf5df81843102bc2ba2560207841
Not only does it look ugly, the search engines will probably not crawl into it. Google has partial support for dynamic URLs, but it is not likely to index all your internal pages unless you have a good PR on your main page to start with. It is best to cast a spell on that URL to change it into the following:
http://yoursite.com/article35.html
[Editor’s Note: It is even better to use a descriptive URL, for example http://www.yoursite.com/Section/Article_Name.html]
How do you cast this spell? By making use of the magic potion called mod-rewrite. What I am about to explain applies to PostNuke (my CMS of choice) and is only for technical wizards; if you don’t understand, feel free to skip to the next section.
In your .htaccess file, you will need to add a rule using regular expressions to convert the URL. The following 2 lines added to your .htaccess in your document root will cast the spell for the example above:
RewriteEngine on
RewriteRule ^article([1-9][0-9]*).* modules.PHP?op=modload&name=News&file=article&sid=$1
You will need to add one RewriteRule line for each cast for different types of URLs. For More details on mod-rewrite, look at http://www.sitepoint.com/print/910. This casting using Mod-Rewrite will internally convert your elegant URL into the ugly one that the CMS expects, but how do you convert from the ugly URL to the elegant one? Most CMSs come with a header and footer includes using which you can append a custom header and footer to all your pages. Assuming that you are using PHP, and assuming that the HTML is in the variable $html, We can use this PHP code in the header or footer (wherever we have the entire html available before sending to the browser client) to substitute all the ugly URLs with elegant ones.
$in = array(
"'(?<!/)modules.PHP?op=modload&name=News&file=article&sid=([0-9]*)'"
);
$out = array("article1.html");
$html = preg_replace($in, $out, $html);
The above example shows only one element in the array but we can have as many elements as we need to cast our various spells.
The session id is usually not necessary; even if it is really critical to the functionality of your website, it need not be in the URL. Most users have cookies enabled, so your CMS can store the session id using cookies. The web server appends the session id to the URL the first time a visitor comes to the website, just in case the user does not have cookies enabled, but search engines do not accept cookies so they always get to see the session id! URL-rewriting for session maintenance can and should be turned off in your webserver settings.
Next: Which CMS to Use and Where to Find Them >>
More Search Optimization Articles
More By Mufad