Create CMS Website

Search engine friendly URLs

The Beginner's Tutorial
How To Create Own Website with CMS Made Simple

Rewrite URLs. Not only for search engines.

Search engine friendly URLs are website addresses that does not contain any dynamic components in it and thus are better readable for humans and search engines. Compare the 2 URLs below:

http://youdomain.com/index.php?page=products http://yourdomain.com/products

What is better? Search engine will find the second version more attractive and will much better index your website. Some pages with query strings in the address (as in the first example) are never indexed, some will take longer time. After setup of your website with CMS Made Simple you will find that the URLs of your pages are built in the first way. We should rewrite them to achieve better results with the website.

If you do not care about search engine, think about the visitors of the website. How easy is it to type or write down the address of the specific page if we do not use the second rewritten version? Imagine your visitor would like to recommend the page. He would do it without difficulties with search engine friendly URL and will fail with the first example.

To enable search engine URLs on your website you have to complete two steps. First of all, you have to modify the file config.php. Start Filezilla, connect to your hosting and click with right click on config.php. Choose “View / Edit”. The file will be opened in text editor. Search in the file for  the section “URL Settings” and replace:

$config['url_rewriting'] = 'none';

with

$config['url_rewriting'] = 'mod_rewrite';

Close the file, save and upload this file back to the server.

In the second step, still using FileZilla go to the directory doc and move the file htaccess.txt into the root directory (in the same directory where config.php is). Rename the moved file to .htaccess (period at the beginning belongs to new file name!). To rename the file right click on it and select “Rename”. If the file disappears after renaming, in FileZilla choose in the top menu Server → Force showing hidden files.

Now your URLs has to be rewritten. Control it on your website. If you get an internal server error, please check the known issues:

  • Your hosting company does not support mod_rewrite
  • You have installed CMS into the sub-directory, e.g. http://yourdomain.com/mycms. In this case you have to edit .htaccess file and replace
    RewriteBase /
    with
    RewriteBase /mycms
    Change the name after slash to your sub-directory.

Hierarchy

Enabling search engine URLs has another useful effect. The URLs contains now the full hierarchy path to the page and not only the name. For example, you have created the page “TV” (tv) and selected the page “Products” (products) as parent page for it. Without rewriting the URL of the page TV is:

http://yourdomain.com/index.php?page=tv

With rewriting the URL of the page is:

http://yourdomain.com/products/tv

The second version is cleaner, looks better for human, can be written down or noticed and is much better for search engines. If you use hierarchy you also have more keywords in your URL, e. g. http://yourdomain.com/buy-a-car/texas.

If you hosting does not support mod_rewrite, I recommend running away. Seriously, the most web hosting has this feature enabled by default, even free webshosting for CMS Made Simple. There is no reason for not enabling it unless the provider is not able to install it. I would not discuss about it, claim it or choose another web hosting.


Comments to "Rewrite URLs. Not only for search engines."

  1. Evan July 24, 2009, 12:04 am

    Much appreciated! Worked like a charm! I'm glad you also noted that if this is installed in a subdirectory to specify it on the htaccess file. That's something many people would miss.


  2. Tristan Woudenberg August 17, 2009, 1:03 pm

    Nice site, wouldn't it be a nice idea to copy over some of your content to the wiki of the CMS Made Simple site as well?


  3. Sofia August 18, 2009, 2:30 pm

    @Tristan Woudenberg
    It is defenitely nice idea to have similar content in Wiki. But a copy of content would produce "duplicate content" in search engines. It means that the content has to be rewritten for Wiki to avoid penalizing. However, rewriting is very time consuming and that is reason for me not doing it at the moment.


  4. Razvan September 12, 2009, 2:09 pm

    Sorry to say it, but the hierarchy is not showing at all. Instead of :

    http://www.myhost.com/services/myservice

    where myservice is a child of services, it prints only

    http://www.myhost.com/myservice

    Any ideas?


  5. Sofia September 12, 2009, 6:25 pm

    @Razvan: You will find in config.php the variable $config['use_hierarchy']. It should be set to "true". There will be no support for switching off hierarchy in the future versions of CMS Made Simple. So that I recommend leaving the default settings.


  6. Razvan September 12, 2009, 6:40 pm

    @Sofia: Thanks. It was turned off by default. Wouldn't it have been more logical to have it ON by default? Anyway, your tip solved my problem. Have a nice week-end!


del.icio.us digg stumbleupon buzzup BlinkList mixx myspace linkedin facebook reddit.com ma.gnolia.com newsvine.com furl.net google yahoo technorati.com

CMS Made Simple Beginner's Guide
Loading...