Multi Tenancy on a Subfolder?

Topics: Administration, Core, General, Troubleshooting
Sep 12, 2012 at 12:01 AM

I've got a client who has a new site I'm trying to help them get going. They have multiple lines of business and they want to have a different functional site for each one, so I figured multi tenancy to the rescue and we have the sites all setup but I found out that they want them to appear as sub folders under the same domain.

So they would appear as and

Now this makes sense given my understanding of the way MVC works, which Orchard is based on, but when I tried to accomplish this the site(s) broke. Does anyone know of a way to get multi-tenancy to work off of sub folders?

Sep 12, 2012 at 5:48 PM

Did you try to set RequestUrlPrefix in the settings.txt for the tenants?

Sep 14, 2012 at 6:03 PM

No, actually I wasn't aware of that setting. I just tried it but it didn't seem to work at first, however after I cycled the app pool it picked up the change and started responding correctly. This works exactly as I was hoping. Odd that there is no UI for it in the multi-tenancy module but it works and that's all that I'm concerned with right now.

Thank you very much for pointing me in the right direction Bertrand!

Sep 17, 2012 at 5:11 PM

Ok, so now I have one last problem, given that I now have multiple sites running under different sub-folders, the client wants to have a non-rendering landing page at the root domain that programmatically redirects the user to one of the tenants based off of some business logic. So if they hit and lets say the business logic has determined they should be directed to how do I get Orchard to accept the request for the root domain and get the business logic in there? My first thought was a plain old default.aspx page at the root but I can't get orchard to serve up that file. I'd like to avoid setting up a tenant for the root domain if I can, as it seems to be overkill for what the page will actually be responsible for (let alone getting server side code into a tenant app).

Sep 17, 2012 at 5:17 PM

Just use IIS's URL rewrite capabilities.

Sep 17, 2012 at 5:24 PM

I thought of that, but the business logic they want to use to determine what tenant they get redirected to is not something I can put in the URL Rewrite criteria. They want to be able to redirect them to a tenant based off what Province/State they are hitting the site from.

My current train of thought is to add a handler to the web.config for /default.aspx and then put my logic in there, does that sound like a good way to go about it?

Sep 17, 2012 at 5:28 PM

Rewrite to a controller action that has this custom logic, and make it redirect accordingly.

Sep 17, 2012 at 8:47 PM

I'm having issues with the login redirect for the admin section on the tenants now. I am getting redirected to instead of

Any way to fix this?

Sep 17, 2012 at 8:51 PM

That may be a bug. Please file it. Workaround could be, again, URL rewrite.

Sep 17, 2012 at 11:36 PM

Submitted, Thanks again. I'll try and add the URL rewrite as a work around for now.