URL rewriting for Mango Blog with IIS 7.5 and Apache 2.2

I recently set up url rewriting for Mango Blog on both IIS 7.5 and Apache 2.2. I followed the excellent guide by Adam Tuttle, but experienced a few issues along the way, so I decided to add a post that may prove helpful to someone else down the road.

The first server that I setup url rewriting on was a Server 2008 box running ColdFusion 9, IIS 7.5 and Mango Blog version 1.6. I pretty much followed Adam's directions exactly, which started with installing Ionic's ISAPI Rewrite Filter. I ran into a few stumbling blocks when following the instructions before I was able to get the filter working correctly. I only wanted to run the url rewriting on one particular site so I opted for a manual installation instead of using the msi installer. I also wanted to use a native 64-bit solution, so I went with the version that was compiled for 64-bits systems. Following the install instructions from Ionic, I attempted to place the IIRF.dll file in the /System32/inetsrv/IIRF/ directory. Setting up the permissions according to the document was not allowing the rewriting to properly load, so I eventually setup the files outside of the Windows directory all together which resolved my issues. That was definitely the most frustrating part of setting up the rewriting for my site. You can use the following link to display a status report, http://localhost/iirfStatus, which will allow you to verify if the filter loaded properly or not.

Once the filter is properly loading you need to add the following rules to your IIRF.ini file. These are taken directly from Adam's blog.

  • #redirect old url's to their new fancy url's
  • RewriteRule ^/(post|page|archives|author).cfm/(.*)$ /$1/$2 [R=301,I,U]
  • #standard mango rewrites
  • RewriteRule ^/(post|page|archives|author)/(.*)$ /$1.cfm/$2 [I,U,L]

After setting up the rewrite rules you still need to configure Mango Blog to use the new search engine safe urls. Starting in version 1.6 of Mango Blog, these settings have been moved from the config.cfm to the settings table in the database. Look for the system/url values and you will see where you can change the values so that the templates no longer contain the .cfm extensions. In order for me to edit the settings table in the MySql Query Browser I had to add a primary key field to the the table.

The other server I setup was running on Railo 3.1 and Apache 2.2. I had to enable the rewrite module in the http.conf file and then I placed my rewrite rules into my .htaccess file for each of the sites I wanted to apply rewrite rules. These are the rules that I ended up using.

  • RewriteEngine on
  • RewriteBase /
  • RewriteRule ^index.cfm$  / [R=301,L,NC]
  • RewriteRule ^archives.cfm/(.*)$  archives/$1 [R=301,NC]
  • RewriteRule ^page.cfm/(.*)$  page/$1 [R=301,NC]
  • RewriteRule ^post.cfm/(.*)$  recipe/$1 [R=301,NC]
  • RewriteRule ^author.cfm/(.*)$  author/$1 [R=301,NC]
  • # archives rule must be located before page rule for paging to work correctly
  • RewriteRule archives/(.*)$    archives.cfm/$1 [PT,L,NC]
  • RewriteRule page/(.*)$    page.cfm/$1 [PT,L,NC]
  • RewriteRule recipe/(.*)$      post.cfm/$1 [PT,L,NC]
  • RewriteRule author/(.*)$    author.cfm/$1 [PT,L,NC]

I've been unable to get the first set of rules to actually change the url in my browser as it appears the the second rules are immediately overriding the rewrite. This is different behavior than I experienced with the rewriting on IIS with the Ionic Rewrite Filter. I'm hoping to still figure this issue out as I would like the old url's to be permanently redirected to the new ses url's. Any ideas or tips on how to properly rewrite the old url's would be greatly welcomed.

The other thing to take note of is that I'm rewriting the post.cfm to recipe instead of post. You can make these changes to provide even easier to remember urls based on the content of your site.

I hope that this is helpful to anyone that is trying to setup url rewriting for Mango Blog.


Adam Tuttle

Hey John, I'm glad you found my guide useful. It sounds like a lot has changed with IIRF (I don't think the status display or the MSI installer were available when I did mine, all those many moons ago). Glad you figured it out.

John Sieber

@Adam - Thanks again for your post which got me started. Microsoft has a rewriting module for IIS 7 also, I'll have to try that out one of these days.

Adam Tuttle

As long as it works well, using the built-in option would be preferable to a 3rd party tool. I haven't used the rewriting in IIS7 though. I'd be interested to see your write-up if you do set Mango up using it.

Edward Beckett

This is interesting ... I'm using a mod of Adam's code on Apache 2.2 and all I've done is add the following and it's working like a champ ... RewriteEngine On RewriteRule archives/(.*) archives.cfm/$1 [PT,L,NC] RewriteRule post/(.*) post.cfm/$1 [PT,L,NC] RewriteRule page/(.*) page.cfm/$1 [PT,L,NC] RewriteRule author/(.*) author.cfm/$1 [PT,L,NC] RewriteRule rss/ feeds/rss.cfm [PT,L,NC] RewriteRule atom/ feeds/atom.cfm [PT,L,NC]

Robert Preville

John, did you ever get Mango blog to run in CFWheels. I have a cfwheels site and I am trying to install mango in a dir off the root called "blog". However, the mango application.cfc is not blank, so wheels does not exclude the "blog" folder from the framework.. any ideas?

John Sieber

Hi Robert, I have not tried to run Mango blog within cfWheels. I'm thinking it should work if you placed your "blog" directory containing Mango within the miscellaneous folder in your cfWheels install. That might not be what you want though. A good place to ask about this would probably be the cfWheels google group. I'm betting that someone will offer a solution.

Write your comment

(it will not be displayed)

Leave this field empty: