mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-02 19:44:02 +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)
|
||||
? tenantShellSettings.RequestUrlHost + port : host);
|
||||
|
||||
if (!string.IsNullOrEmpty(tenantShellSettings.RequestUrlPrefix))
|
||||
result += "/" + tenantShellSettings.RequestUrlPrefix;
|
||||
|
||||
if (!string.IsNullOrEmpty(urlHelper.RequestContext.HttpContext.Request.ApplicationPath))
|
||||
result += urlHelper.RequestContext.HttpContext.Request.ApplicationPath;
|
||||
|
||||
if (!string.IsNullOrEmpty(tenantShellSettings.RequestUrlPrefix))
|
||||
result += "/" + tenantShellSettings.RequestUrlPrefix;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
@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>
|
||||
</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>
|
||||
<legend>@T("Database Setup")</legend>
|
||||
|
||||
@@ -14,6 +14,11 @@
|
||||
@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>
|
||||
</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>
|
||||
<legend>@T("Database Setup")</legend>
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace Orchard.Setup.Controllers {
|
||||
[ValidateInput(false), Themed]
|
||||
public class SetupController : Controller {
|
||||
private readonly IViewsBackgroundCompilation _viewsBackgroundCompilation;
|
||||
private readonly ShellSettings _shellSettings;
|
||||
private readonly INotifier _notifier;
|
||||
private readonly ISetupService _setupService;
|
||||
private const string DefaultRecipe = "Default";
|
||||
@@ -24,8 +25,10 @@ namespace Orchard.Setup.Controllers {
|
||||
public SetupController(
|
||||
INotifier notifier,
|
||||
ISetupService setupService,
|
||||
IViewsBackgroundCompilation viewsBackgroundCompilation) {
|
||||
IViewsBackgroundCompilation viewsBackgroundCompilation,
|
||||
ShellSettings shellSettings) {
|
||||
_viewsBackgroundCompilation = viewsBackgroundCompilation;
|
||||
_shellSettings = shellSettings;
|
||||
_notifier = notifier;
|
||||
_setupService = setupService;
|
||||
|
||||
@@ -127,7 +130,7 @@ namespace Orchard.Setup.Controllers {
|
||||
_viewsBackgroundCompilation.Stop();
|
||||
|
||||
// redirect to the welcome page.
|
||||
return Redirect("~/");
|
||||
return Redirect("~/" + _shellSettings.RequestUrlPrefix);
|
||||
} catch (Exception ex) {
|
||||
Logger.Error(ex, "Setup failed");
|
||||
_notifier.Error(T("Setup failed: {0}", ex.Message));
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace Orchard.Environment {
|
||||
.Where(group => host.EndsWith(group.Key, StringComparison.OrdinalIgnoreCase))
|
||||
.SelectMany(group => group
|
||||
.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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user