CMSMS Pretty URLs

I often have clients come to me for help with making their URL’s user friendly for aesthetic and SEO purposes.  This can be done in any content management system (CMS) but is somewhat tricky to do in CMSMS since documentation is somewhat sketchy.

Part of the problem is there is no way to modify this setting through the Admin panel.  Instead the webmaster must modify the config.php file manually which is normally created for you when installing CMSMS.  Never fear though, the solution is actually quite simple once you understand the system.  There are several options that control the behavior of the URLs.  They are listed here, along with an explanation of what they do.

CMSMS Pretty URL Config Settings

  • assume_mod_rewrite: the basis of URL rewriting.  This value needs to be set to “true” for any rewriting to occur.  If you are using mod_rewrite for the URL rewriting, then you will also need to edit your .htaccess file (read on for more details).
  • page_extension: this controls what the page extension is on the end of your rewritten links.  For example, if you want all links to end in “.html” (so they look like static pages) then simply set this value to ‘.html’.  You can also set it to a trailing slash which is my personal favorite.
  • internal_pretty_urls: If you don’t have the mod_rewrite module for Apache and you still want pretty URLs, then this must be enabled.  This makes it so the url looks like: http://www.mydomain.com/index.php/your-page.html.  It’s not a perfect URL, but it’s a good solution if you can’t use mod_rewrite for some reason.  If you choose this then you do not need to edit your .htaccess file.
  • use_hierarchy: this makes it so the page hierarchy shows up in the URL structure.   For instance, if  “mysubpage” has a parent of “mypage”, then the URL will look like: http://www.mydomain.com/mypage/mysubpage.html.  This option needs to be enabled if you need to rewrite modules such as news.

Editing .htaccess for Pretty URLs

If you will be using mod_rewrite then we also need to edit the .htaccess file so that URLs will be rewritten correctly by the Apache engine.  This is always the part that people forget and they wonder why the rewrite doesn’t work, so don’t forget about it!

To do this create a file called “.htaccess” (yes, that’s a filename with no name and an “htaccess” extension) or edit your existing one, and add this code at the end of it:

# CMSMS Rewriting
# Set assume mod_rewrite to true in config.php and clear CMSMS cache
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
# END CMSMS

For those of you that think this looks like gibberish this is basically saying “Apache, if you can’t find the requested file or folder, then use index.php instead and pass in the old URL as a parameter”.  What that does is now the URL you tried to access (like “http://www.mydomain.com/page/subpage.html”) is now passed into CMSMS, and it internally handles the lookup to request the actual page data.

Finally, we need to clear the CMSMS cache by going into the Admin panel -> Site Admin -> Global Settings, and clicking the “Clear Cache” button.  That’s it!  Your URLs are now rewritten! Whew!

In summary, here are the basic steps to get Pretty URLs working:

  1. Modify config.php options to your liking.  In particular you need to at least turn on the assume_mod_rewrite option.
  2. If internal_pretty_urls is FALSE then you need to edit the .htaccess file with the above block of code.
  3. Clear the CMSMS cache.
  4. Test your site and make sure everything works.

Custom Coding Solutions

Well, I finally got around to getting a website up to offer my services. As you can see from my “About Page” I’ve been coding for several years and can pretty much do anything programming/coding related that you need done. Aside from my day job as a programmer, I have been doing freelance coding for the last few years. In that time I’ve done everything from creating custom programming solutions for webmasters, to your general site transfers, host moves, html to CMS migration, and of course troubleshooting. You name it, and I’ve done it or had to fix it.

Some people like to build things, some people like to break things, I like to code. No job is too small and I like good projects. I have created some great custom apps for webmasters and I’m open to discussing any project big or small. So, if you have a question or want some additional information, please fill out the contact form and I’ll get back to you ASAP.

Here are just a few examples of sites I’ve done Custom Coding on:

Twilight Gear

Felt Poker

Hand History Replayer

Also, here is some more information about the type of coding I’m very experienced with:

  • Web coding (such as PHP, flash, or javascript)
  • Migrating static sites or designer test pages to a CMS-based system (particularly CMSMS)
  • URL Rewriting (especially for SEO purposes)
  • HTML and/or css tweaks
  • Server and database setup and administration
  • Website migration
  • and many others!

Just another WordPress weblog