Blog

Removing the SiteID from URLs in Mura

UPDATE: Starting in Mura 5.2 you can now simply set your /config/settings.ini.cfm siteIDInURLs attribute to 0.

This is a request that comes up over and over again so I thought that I would blog about how to remove the siteID directory from the URLs that are generated by Mura. The siteIDs are there to provide context for multiple sites to exist on a single install. If you only have one site or each site in the install is bound to a unique domain then you can easily remove them. This process will probably be a quick little toggle in the admin at some point, but for now here are the steps:

1. Go to your local contentRenderer.cfc (/[siteid]/includes/contentRenderer.cfc) and uncomment the getURLStem method by removing the <!--- --->.

<cffunction name="getURLStem" access="public" output="false" returntype="string"><cfargument name="siteID"><cfargument name="filename"><cfif arguments.filename neq ''><cfif application.configBean.getStub() eq ''><cfreturn "/index.cfm" & "/" & arguments.filename & "/"/><cfelse><cfreturn application.configBean.getStub() & "/" & arguments.filename & "/" /></cfif><cfelse><cfreturn "/" /></cfif></cffunction>

2. Edit the index.cfm at the Mura root to include tasks/content/contentServerRoot.cfm and comment out the redirect:

<!---<cfinclude template="tasks/content/redirect.cfm">---><cfinclude template="tasks/content/contentServerRoot.cfm">

Once this is done the URLs that Mura generates will look this this:

http://www.domain.com/index.cfm/path/to/file/

As you can see there is still an "index.cfm" in the URL. If you want to get rid of that you will need rely on something like apache mod_rewrite or isapi-rewrite or a free option to isapi-rewrite. Jamie Krug has a good blog that talks about how to do it with mod_rewrite.