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.

Comments

Kevin Barnes

Regarding removing the siteID from the URL: When using the Restrict Access feature for a page, it throws an error when I try to visit the page. I have a page that lists all of my photo galleries, which I want to secure behind a login. When I use the URL hack to get rid of the siteID I end up with a page not found error. Unrestricted it works just fine. Also, everything else works just fine, any ideas?

August 25, 2009, 4:40 PM
Jamie Krug

@Kevin: If it's not too late... you might want to check out the following forum thread, as there were a few other little details involved in getting all directory references working properly...

http://www.getmura.com/forum/messages.cfm?threadid=4EE1B98E-BA4E-4A2D-8CCACFD78269E26C

October 12, 2009, 2:45 PM
gurock

Is there a definitive guide to solving the "404 on all but the home page" SES problem. I'm am a bit of a newbee and there are just so many fragments to this issue that it is confusing.

Thanks for any help you can offer.

December 9, 2009, 1:36 AM
Jamie Krug

@gurock: I'm not sure what 404 problem you're referring to. It could have something to do with the servlet container running your CFML engine, or Web server URL rewriting rules. There really can't be one "definitive" guide, because there are many major Web servers, at least 3 CFML engine options and plenty of servlet containers to choose from. The Mura configuration is fairly straightforward, but the Web server and servlet container level has variations.

December 9, 2009, 10:49 AM
David

I can get this working by adding contentServerRootStub to the main contentServer.cfc in the root, but once i do this i cannot use the Comments, Rater, Calendar, or other common system tools. Any suggestions?

Thanks,

David

January 16, 2010, 1:15 AM
Jamie Krug

@David: I don't follow exactly what you did, but you had to do something more than what is outlined above to get this to work? You should not need to. Can you provide an example URL that properly displays the page and what URL(s) are not working (e.g., what is the comment form action)? By "cannot use" do you mean you're seeing 404 errors? Other error types?

January 19, 2010, 9:19 PM
David

@Jaime,

It was actually a bug having to do with Mura and OpenBD playing nice. Matt got it all fixed. The directions above though are not quite right however though for everything to work. What i did was as follows:

1) Copied the Jar file to my OpenBD Lib directory.

2) Added the 2 lines of the Web.xml AFTER each <servlet> and <servlet-mapping> of the web.xml in my WEB-INF.

3) Uncommented the getURLStem as mentioned above.

4) Changed the line as mentioned above for the Mura index.cfm from <cfinclude template="tasks/content/redirect.cfm"> to

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

5) Changed Mura root contentServer.cfm from <cfinclude template="tasks/content/contentServer.cfm"> to <cfinclude template="tasks/content/contentServerRootStub.cfm">

6) In my settings.ini.cfm file i changed the stub to /go

Restarted everything and all seems fine now that Matt fixed the OpenBD issues. Still not sure how to remove the go, so if you have any suggestions on that i'd highly appreciate it! I'm on a dedicated Unix box just an fyi.

Thanks,

David

January 19, 2010, 10:31 PM
Jamie Krug

@David: I see :) Using that jar and the "go" stub is one option. That's not necessary if you have Apache in front of your servlet container, and can leverage mod_rewrite. Check out the thread I linked in an earlier comment, above. You could also keep what you have now and use mod_rewrite to "insert" the "go" in URLs, in which case you'd just remove "go" from the stub setting.

January 19, 2010, 10:36 PM
David

@Jaime,

Thanks for the thoughts! I have actually checked out your post, as well as several posts on your blog (which rocks btw! :) ), and attempted to do what you recommended, but i was unable to achieve the results. I think my server configuration my be the culprit. If you're interested to have a peek, let me know, so perhaps others that have a similar problem can resolve it too.

Thanks again,

David

January 20, 2010, 1:37 AM
Jamie Krug

@David: Hey, thanks for the kind words. I'd be happy to have a peak if you'd like to e-mail me some details: jamiekrug is my user name at that Gmail domain name :) Then, we can post something in the forum if we come up with any useful tips or how-to type stuff.

January 20, 2010, 10:18 AM
Post a Comment
  1. Leave this field empty

Required Field