I have been involved in setting up a new Mura site on Windows 2008 Server. Mura is a full featured CMS written in ColdFusion.

By default Mura URLs look something like /index.cfm/SiteID/pagename. So for example the contact us page might look like /index.cfm/default/contact-us. Not a great URL. But its fairly simple to translate into /contact-us which is much nicer.

Getting rid of the SiteID

Getting rid of the siteID is easy in the newest version of Mura. In the config/settings.ini.cfm file there is a setting named “siteidinurls”. Set this to 0 and Mura will no longer add the siteID to the URLs it generates. Of course this only works if you plan on only using Mura for one site. If you had more than one site, Mura wouldn’t know which one you are trying to access. There are several ways to get around this if you have more than one site, but I won’t get into that in this article.

Getting rid of the index.cfm

Getting rid of the index.cfm takes a little more work. There is another setting in the ini file called indexfileinurls. Setting this to 0 will remove the index.cfm from the URLs Mura generates. But when you click on any of those links you are going to get the 404 page. To fix this, you’ll need to tweak your webserver.

Apache is pretty straight forward, as you would expect. Enable the mod_rewrite module and drop this into an .htaccess file in your webroot:

RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^([a-zA-Z0-9/-]+)$ /index.cfm%{REQUEST_URI} [PT]

Our site happens to be hosted on Windows 2008 Server / IIS7. To do the rewriting on II7 you’ll need to install Microsoft’s URL rewriting extension. You can get it from here: http://www.iis.net/download/URLRewrite

Once its installed, open IIS Manager. Click on your website, then double click on the new URL rewrite icon.


Select Import Rules from the right hand side.

Then paste the apache lines above into the Rewrite rules box.

Instantly you’ll see the new rules appear in the Converted Rules box. Click Apply in the upper right.

Now change the Mura ini file I mentioned above, then click the Reload link in your Mura admin.

That’s it!

13 Comments

  1. Jose Galdamez says:

    I went through this setup after some trial and error a few months ago (with Matt Levine's help of course). Man, the clean URLs are just so… clean. Great guide, Ryan. This is exactly as I remember doing it.

  2. Doug Boude says:

    Outstanding tutorial, man! Concise, to the point, and with PICTURES! I had no idea I could import rules into IIS7…thought I was going to have to just learn to write them IIS-style. Thanks again, saved me a lot of time!

  3. Greg Moser says:

    Thanks for the great tutorial… I have used this countless times.  However one issue that I ran into was spaces in the URL.  With mura 5.4 now categories and tags are put in the url as /tag/my%20tag/ however the regex expression that you have doesn't account for spaces in the url.  I changed it to the following to account for spaces and now it works great!:

    ^([\x20a-zA-Z0-9/-]+)$

    Thanks!

  4. Scott says:

    It appears you're also missing _ characters in the regex.

  5. Fluid says:

    @Ryan – Seriously appreciate this post! Up and running faster than I could copy and paste!

    @Greg Moser – Thanks for leading me here via the Mura forums!

  6. Greg Moser says:

    For any future readers, in the latest version of mura it now automatically creates a web.config file with rewrite rules that will do the rewrite for you in IIS.  All you need to do is go to the web root folder and and change web.config.txt to web.config.

    -Greg

  7. Josen Ruiseco says:

    I just downloaded and installed the latest version of Mura using the installer. There is no web.config or web.config.txt included. Does someone know where I could get a copy of that file?

  8. Josen Ruiseco says:

    Apparently this file is not included in the installer but exists in the standard download file set.
    It appears to be a set of rules for IIS7.

    Does anyone have the exact rule set for Ionic Rewriter on IIS 6.5?

  9. Josen Ruiseco says:

    I've been plugging away and come up with the following:

    RewriteEngine         ON
    RewriteCond         %{DOCUMENT_ROOT}%{REQUEST_URI}     !-d
    RewriteRule         ^([\x20a-zA-Z0-9/-]+)$         /index.cfm%{REQUEST_URI}

    The rules work everywhere I've tried except for searches:

    http://www.domain.com/test-page/tag/Page/?Keywords=test&display=search&newSearch=true&noCache=1

    When I manually add in index.cfm into the URL, the search page displays properly:

    http://……../index.cfm/test-page/tag/Page/?Keywords=test&display=search&newSearch=true&noCache=1

    It seems clear that the rule is not capturing this condition. Any thoughts?

  10. Ronnie says:

    I used this, and it works great for the interior pages (www.domain.com/about-us), yet the home page still adds "index.cfm" (www.domain.com/index.cfm).

    Any thoughts?

  11. Greg Moser says:

    @Ronnie

    When you say that it still adds index.cfm to the home page… where are you clicking that link from?  If you are clicking on the site name from the admin, that could be a bug in an older version of Mura that no longer exists (I think i submitted the fix about 2 months ago).  Try updating your core and testing again.

    -Greg

  12. Ronnie says:

    Either when I click the home page from the live site or even when I just type in http://www.domain.com it adds the index.cfm to the end.

  13. Ronnie says:

    Still happening…If you go to http://www.themodmedia.com, the URL will add /index.cfm to the end of it.

    Other pages like http://www.themodmedia.com/about-mod-media work just fine. It's just on the home page.

    Any suggestions?

Leave a Reply

You must be logged in to post a comment.