Even prettier SES URLs in Mango
Adam
Tonight I installed Ionic's ISAPI Rewrite filter on my server and set it up for this domain. I've always been a fan of the www-less URL, so now you don't have a choice — I'm redirecting you here. In addition to that, I'm making urls like /page.cfm/projects/burnt-mango accessable as /page/projects/burnt-mango. I even took it a step further and redirect you to the new pretty format from the old ugly format, in case there are any errant URL's going around.
The first thing I had to do, once I got the ISAPI filter installed and running, was to define my rewrite rules:
###### force removal of www. prefix on all requests
RewriteCond %{HTTP_HOST} www.fusiongrokker.com(.*) [I]
RewriteRule ^/(.*) http://fusiongrokker.com/$1 [I,R=301,U,L]
This takes care of getting rid of "www." from the URL.
###### Mango Blog stuff
#redirect old url's to their new fancy url's
RewriteRule ^/post.cfm/(.*)$ /post/$1 [R=301,I,U]
RewriteRule ^/page.cfm/(.*)$ /page/$1 [R=301,I,U]
RewriteRule ^/archives.cfm/(.*)$ /archives/$1 [R=301,I,U]
RewriteRule ^/author.cfm/(.*)$ /author/$1 [R=301,I,U]
These will redirect you from the old page.cfm/page-name format to the new page/page-name format.
#standard mango rewrites
RewriteRule ^/post/(.*)$ /post.cfm/$1 [I,U,L]
RewriteRule ^/page/(.*)$ /page.cfm/$1 [I,U,L]
RewriteRule ^/archives/(.*)$ /archives.cfm/$1 [I,U,L]
RewriteRule ^/author/(.*)$ /author.cfm/$1 [I,U,L]
And lastly, these rewrite the new page/page-name format as page.cfm/page-name so that Mango can still interpret them correctly.
Notice that for all of my redirects ([R] flag) I'm using R=301. 301 is the status code for Moved Permantently, rathern than the default of 302, Moved Temporarily. This will tell search engine spiders and other smart things to update themselves; as well as preserve any PageRank that the old URL might have had. The L flag stands for "Last" and indicates that no further rules should be processed after this one is matched. In this case, I'm using it to prevent circular references, where going to page/page-name rewrites as page.cfm/page-name, which redirects to page/page-name which rewrites as… yeah.
Update: As suggested by Seb Duggan in the comments, I've combined the above rules into these two simple lines:
#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 the rules are in place, we have to tell Mango how to output URLs in the new format. It uses a special file called config.cfm which contains your blog settings.
These are just the relevant settings, of course. They should use the format that you want the user to see the URL as, because this is what Mango uses to format its links.
I keep finding more and more reasons to love Mango. This is just another one of them.
Posted in Mango |
12 comments


