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.

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, 9:40 AM
Reply
Flag as Spam
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, 7:45 AM
Reply
Flag as Spam
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 8, 2009, 5:36 PM
Reply
Flag as Spam
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, 2:49 AM
Reply
Flag as Spam
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 15, 2010, 5:15 PM
Reply
Flag as Spam
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, 1:19 PM
Reply
Flag as Spam
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, 2:31 PM
Reply
Flag as Spam
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, 2:36 PM
Reply
Flag as Spam
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 19, 2010, 5:37 PM
Reply
Flag as Spam
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, 2:18 AM
Reply
Flag as Spam
Jeremie

Hi,

Thank you for the great CMS.

I tried to set the siteidinurls to 0, but no change at all. I reloaded the app, but also nothing.

I am testing the Core Version 5.2.2014 on MacOS. Any thing I am doing wrong?

April 3, 2010, 7:51 PM
Reply
Flag as Spam
Matt Levine

If this is a Mura instance is one that was auto updated from 5.1 you will need to manually replace the www/index.cfm file from svn.

http://svn.blueriver.com/mura/trunk/www/index.cfm

If that is not the issue, I will do some testing to see if i can recreate the issue.

April 4, 2010, 7:17 AM
Reply
Flag as Spam
Jeff Ireland

I'm having trouble getting this to work. I followed the instructions above and siteID and index.cfm were removed from urls. As a result, only the home page loads. All links to other pages aren't working. My end result would be to have the index.cfm be there and just remove the site id. Once making this change, do I need to recreate all my pages? Thanks!

May 3, 2010, 10:02 PM
Reply
Flag as Spam
Matt Levine

You'll want your settings to look like this: siteidinurls=0 indexfileinurls=1 After making the change you will need to reload the app. All you current content will work fine as well.

May 4, 2010, 3:38 AM
Reply
Flag as Spam
Jeff Ireland

@Matt Thanks for your help. Unfortunately, that still didn't do it. I made the changes you recommended to the settings.ini.cfm file and index.cfm is still not showing up in the url. I can't imagine that I did anything incorrectly in the above steps. Any other ideas or info i could provide that would help?

May 4, 2010, 5:01 AM
Reply
Flag as Spam
Jeff Ireland

@Matt Not sure if this is the recommended solution but, I got it to work. It was a line in contentRenderer.cfc. Was: <cfreturn "/" & arguments.filename & "/"/> Changed to: <cfreturn "/index.cfm/" & arguments.filename & "/"/> Thanks for your help!

May 4, 2010, 5:11 AM
Reply
Flag as Spam
Jamie Krug

With Mura 5.2 (as the "[INVALID]" note at the top mentions), this post is pretty much completely null and void. In fact, the main problem is likely going to be folks that have custom contentRenderer.cfc files in siteID folders, with a getURLStem() method. The fix is quite simple: if you have 5.2+ and have siteidinurls and indexfileinurls set in your settings.ini.cfm, then be sure you do *not* have a getURLStem() method defined in site contentRenderer.cfc files. If you do, just [INVALID] the getURLStem() method from your siteIDs' contentRenderer, and let the global contentRenderer.cfc handle the getURLStem() method.

May 4, 2010, 6:24 AM
Reply
Flag as Spam
Jamie Krug

Okay, so I recall Blue River mentioning implementing the Portcullis SQL Injection/XSS filter, and it looks like it really messed up my prior comment :( The two "[INVALID]" strings you see were added as a replacement for the words updat3 and d3l3t3 (Es replaced with 3s to avoid filtering again), respectively. In short, remove the getURLStem() function from any siteID directory contentRenderer.cfc files and all will work fine with the right version and the new settings.ini.cfm properties: siteidinurls and indexfileinurls.

May 4, 2010, 6:29 AM
Reply
Flag as Spam
Matt Levine

@krug

I look into taming portcullis a little.

May 4, 2010, 8:31 AM
Reply
Flag as Spam
Matt Levine

That Portcullis filtering was way to aggressive. I tuned it up a little. Please feel free to say update and delete at will.

May 4, 2010, 8:33 AM
Reply
Flag as Spam
Andrew Schwabe

I just posted a blog entry on how to configure Apache to remove index.cfm from your URLs

December 12, 2010, 12:35 PM
Reply
Flag as Spam
Post a Comment

Required Field