In this tutorial we will show you how to enable SEF in CMS Made Simple.

CMSMS provides two ways to use SEF URLs – an internal mechanism (through PHP) and through rewrite rules (using mod_rewrite).

Note that you can use only one method for your CMS (i.e. you cannot have both the internal mechanism and mod_rewrite enabled).

Both methods work flawlessly on all FastWebHost servers, so which method you’ll use depends solely on your preference.

No matter which method you choose, you’ll have to edit the config.php file to enable Search Engine Friendly URLs.

The exact section in the config.php file you’ll need to modify to enable SEF is:

#------------
#URL Settings
#------------

#Show mod_rewrite URLs in the menu? You must enable 'use_hierarchy' for this to work for modules
$config['assume_mod_rewrite'] = false;

#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '';

#If you don't use mod_rewrite, then would you like to use the built-in
#pretty url mechanism?  This will not work with IIS and the {metadata} tag
#should be in all of your templates before enabling.
$config['internal_pretty_urls'] = false;

#If you're using the internal pretty url mechanism or mod_rewrite, would you like to
#show urls in their hierarchy?  (ex. http://www.mysite.com/parent/parent/childpage)
$config['use_hierarchy'] = false;

#If using none of the above options, what should we be using for the query string
#variable?  (ex. http://www.mysite.com/index.php?page=somecontent)
$config['query_var'] = 'page';

The comments (the lines that start with #) above each setting say pretty much all about it.

Now let’s take a closer look at each of the two methods to use SEF URLs in CMS Made Simple.

Using the internal pretty URLsdivider

A SEF URL processed with the internal mechanism will look like:

http://yourdomainname.com/cmsms/index.php/parent_item/child_item

In order to enable the internal pretty URLs option, you should open the config.php file inside your CMSMS installation directory and change this line:

$config['internal_pretty_urls'] = false;

to

$config['internal_pretty_urls'] = true;

Using mod_rewritedivider

A SEF URL processed with mod_rewrite will look like:

http://yourdomainname.com/cmsms/parent_item/child_item

In order to use SEF URLs with mod_rewrite, you should open the config.php file inside your CMSMS installation directory and change this line:

$config['assume_mod_rewrite'] = false;

to

$config['assume_mod_rewrite'] = true;

Then you should add the following lines to your .htaccess file (if you don’t have an .htaccess file, you can easily create one through cPanel > File Manager):

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]

(If you have already added the additional security rules to your .htaccess files, you won’t have to add the above lines)

Two settings that can be used with both SEF methods are:

$config['page_extension'] = '';

and

$config['use_hierarchy'] = false;

Any string you add as a page extension will be added to the SEF URLs. For example, if you want your URLs to look like:

http://yourdomainname.com/cmsms/index.php/parent_item/child_item.htm

or

http://yourdomainname.com/cmsms/parent_item/child_item.htm  

(depending on which SEF method you are using)

you should modify the page_extension setting as follows:

$config['page_extension'] = '.htm';

With the use_hierarchy setting you can make your URLs reflect their location in the content hierarchy. If use_hierarchy is disabled, a page URL would look like:

http://yourdomainname.com/cmsms/index.php/child_item /http://yourdomainname.com/cmsms/child_item (the parent item will not be shown in the URL)

If use_hierarchy is enabled, a page URL would look like:

http://yourdomainname.com/cmsms/parent_item/child_item /http://yourdomainname.com/cmsms/index.php/parent_item/child_item

To enable SEF hierarchy, change this line:

$config['use_hierarchy'] = false;

to

$config['use_hierarchy'] = true;