mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
#18639: Fixing multi-tenancy Url Prefix
Work Item: 18639 --HG-- branch : 1.x
This commit is contained in:
@@ -15,12 +15,12 @@ namespace Orchard.MultiTenancy.Extensions {
|
|||||||
!string.IsNullOrEmpty(tenantShellSettings.RequestUrlHost)
|
!string.IsNullOrEmpty(tenantShellSettings.RequestUrlHost)
|
||||||
? tenantShellSettings.RequestUrlHost + port : host);
|
? tenantShellSettings.RequestUrlHost + port : host);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(tenantShellSettings.RequestUrlPrefix))
|
|
||||||
result += "/" + tenantShellSettings.RequestUrlPrefix;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(urlHelper.RequestContext.HttpContext.Request.ApplicationPath))
|
if (!string.IsNullOrEmpty(urlHelper.RequestContext.HttpContext.Request.ApplicationPath))
|
||||||
result += urlHelper.RequestContext.HttpContext.Request.ApplicationPath;
|
result += urlHelper.RequestContext.HttpContext.Request.ApplicationPath;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(tenantShellSettings.RequestUrlPrefix))
|
||||||
|
result += "/" + tenantShellSettings.RequestUrlPrefix;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,11 @@
|
|||||||
@Html.TextBoxFor(m => m.RequestUrlHost, new { @class = "textMedium" })
|
@Html.TextBoxFor(m => m.RequestUrlHost, new { @class = "textMedium" })
|
||||||
<span class="hint">@T("Example: If host is \"orchardproject.net\", the tenant site URL is \"http://orchardproject.net/\"")</span>
|
<span class="hint">@T("Example: If host is \"orchardproject.net\", the tenant site URL is \"http://orchardproject.net/\"")</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="@Html.FieldIdFor(m => m.RequestUrlPrefix)">@T("URL prefix")</label>
|
||||||
|
@Html.TextBoxFor(m => m.RequestUrlPrefix, new { @class = "textMedium" })
|
||||||
|
<span class="hint">@T("Example: If prefix is \"site1\", the tenant URL prefix is \"http://orchardproject.net/site1\"")</span>
|
||||||
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>@T("Database Setup")</legend>
|
<legend>@T("Database Setup")</legend>
|
||||||
|
|||||||
@@ -14,6 +14,11 @@
|
|||||||
@Html.TextBoxFor(m => m.RequestUrlHost, new { @class = "textMedium" })
|
@Html.TextBoxFor(m => m.RequestUrlHost, new { @class = "textMedium" })
|
||||||
<span class="hint">@T("Example: If host is \"orchardproject.net\", the tenant site URL is \"http://orchardproject.net/\"")</span>
|
<span class="hint">@T("Example: If host is \"orchardproject.net\", the tenant site URL is \"http://orchardproject.net/\"")</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="@Html.FieldIdFor(m => m.RequestUrlPrefix)">@T("URL prefix")</label>
|
||||||
|
@Html.TextBoxFor(m => m.RequestUrlPrefix, new { @class = "textMedium" })
|
||||||
|
<span class="hint">@T("Example: If prefix is \"site1\", the tenant URL prefix is \"http://orchardproject.net/site1\"")</span>
|
||||||
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>@T("Database Setup")</legend>
|
<legend>@T("Database Setup")</legend>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ namespace Orchard.Setup.Controllers {
|
|||||||
[ValidateInput(false), Themed]
|
[ValidateInput(false), Themed]
|
||||||
public class SetupController : Controller {
|
public class SetupController : Controller {
|
||||||
private readonly IViewsBackgroundCompilation _viewsBackgroundCompilation;
|
private readonly IViewsBackgroundCompilation _viewsBackgroundCompilation;
|
||||||
|
private readonly ShellSettings _shellSettings;
|
||||||
private readonly INotifier _notifier;
|
private readonly INotifier _notifier;
|
||||||
private readonly ISetupService _setupService;
|
private readonly ISetupService _setupService;
|
||||||
private const string DefaultRecipe = "Default";
|
private const string DefaultRecipe = "Default";
|
||||||
@@ -24,8 +25,10 @@ namespace Orchard.Setup.Controllers {
|
|||||||
public SetupController(
|
public SetupController(
|
||||||
INotifier notifier,
|
INotifier notifier,
|
||||||
ISetupService setupService,
|
ISetupService setupService,
|
||||||
IViewsBackgroundCompilation viewsBackgroundCompilation) {
|
IViewsBackgroundCompilation viewsBackgroundCompilation,
|
||||||
|
ShellSettings shellSettings) {
|
||||||
_viewsBackgroundCompilation = viewsBackgroundCompilation;
|
_viewsBackgroundCompilation = viewsBackgroundCompilation;
|
||||||
|
_shellSettings = shellSettings;
|
||||||
_notifier = notifier;
|
_notifier = notifier;
|
||||||
_setupService = setupService;
|
_setupService = setupService;
|
||||||
|
|
||||||
@@ -127,7 +130,7 @@ namespace Orchard.Setup.Controllers {
|
|||||||
_viewsBackgroundCompilation.Stop();
|
_viewsBackgroundCompilation.Stop();
|
||||||
|
|
||||||
// redirect to the welcome page.
|
// redirect to the welcome page.
|
||||||
return Redirect("~/");
|
return Redirect("~/" + _shellSettings.RequestUrlPrefix);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.Error(ex, "Setup failed");
|
Logger.Error(ex, "Setup failed");
|
||||||
_notifier.Error(T("Setup failed: {0}", ex.Message));
|
_notifier.Error(T("Setup failed: {0}", ex.Message));
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ namespace Orchard.Environment {
|
|||||||
.Where(group => host.EndsWith(group.Key, StringComparison.OrdinalIgnoreCase))
|
.Where(group => host.EndsWith(group.Key, StringComparison.OrdinalIgnoreCase))
|
||||||
.SelectMany(group => group
|
.SelectMany(group => group
|
||||||
.OrderByDescending(settings => (settings.RequestUrlPrefix ?? string.Empty).Length))
|
.OrderByDescending(settings => (settings.RequestUrlPrefix ?? string.Empty).Length))
|
||||||
.FirstOrDefault(settings => settings.State.CurrentState != TenantState.State.Disabled && appRelativePath.StartsWith(settings.RequestUrlPrefix ?? string.Empty, StringComparison.OrdinalIgnoreCase));
|
.FirstOrDefault(settings => settings.State.CurrentState != TenantState.State.Disabled && appRelativePath.StartsWith("~/" + (settings.RequestUrlPrefix ?? string.Empty), StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
return mostQualifiedMatch ?? _fallback;
|
return mostQualifiedMatch ?? _fallback;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user