Skip to content

Commit

Permalink
v 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
sachatrauwaen committed Nov 22, 2014
1 parent c0c3177 commit 4c90cd1
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 112 deletions.
9 changes: 4 additions & 5 deletions HttpModules/FriendlyUrlProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,12 @@ public override string FriendlyUrl(TabInfo tab, string path, string pageName, st
}
if (!string.IsNullOrEmpty(CultureCode))
{
var primaryAliases = DotNetNuke.Entities.Portals.Internal.TestablePortalAliasController.Instance.GetPortalAliasesByPortalId(PortalId).ToList();
var alias = primaryAliases.FirstOrDefault(a => a.CultureCode == CultureCode);
var primaryAliases = DotNetNuke.Entities.Portals.Internal.TestablePortalAliasController.Instance.GetPortalAliasesByPortalId(PortalId).ToList().Where(a => a.IsPrimary == true);
var alias = primaryAliases.FirstOrDefault(a => string.Equals(a.CultureCode, CultureCode, StringComparison.InvariantCultureIgnoreCase) );
if (alias != null) {
portalAlias = alias.HTTPAlias;
}


DefaultPortalAlias = portalAlias;
}
var DefaultAlias = primaryAliases.FirstOrDefault(a => string.IsNullOrEmpty(a.CultureCode));
if (DefaultAlias != null)
{
Expand Down
16 changes: 10 additions & 6 deletions HttpModules/UrlRewriteModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,14 @@ private void RewriteUrl(HttpApplication app, out string portalAlias) {
app.Response.End();
} else if (action.DoRedirect) {
app.Context.Items.Add("UrlRewrite:RedirectUrl", action.RedirectUrl);

app.Response.AppendHeader("X-Redirect-Reason", action.Raison);
if (action.Status == 302)
{
{
app.Response.Redirect(action.RedirectUrl, true);
}
else
{
app.Response.Status = "301 Moved Permanently";
app.Response.AppendHeader("X-Redirect-Reason", action.Raison);
app.Response.Status = "301 Moved Permanently";
app.Response.AddHeader("Location", action.RedirectUrl);
app.Response.End();
}
Expand Down Expand Up @@ -313,6 +312,7 @@ public void OnBeginRequest(object s, EventArgs e)
if (childAlias.IndexOf(domainName, StringComparison.OrdinalIgnoreCase) == -1)
{
//redirect to the url defined in the alias
app.Response.AppendHeader("X-Redirect-Reason", "alias parameter");
response.Redirect(Globals.GetPortalDomainName(childAlias, request, true), true);
}
else //the alias is the same as the current domain
Expand Down Expand Up @@ -357,6 +357,7 @@ public void OnBeginRequest(object s, EventArgs e)
{
strURL += app.Request.Url.PathAndQuery;
}
app.Response.AppendHeader("X-Redirect-Reason", "not correct domain");
response.Redirect(strURL, true);
}
}
Expand Down Expand Up @@ -398,7 +399,7 @@ public void OnBeginRequest(object s, EventArgs e)
portalAliasInfo.PortalID = portalId;
portalAliasInfo.HTTPAlias = portalAlias;
portalAliasController.AddPortalAlias(portalAliasInfo);

app.Response.AppendHeader("X-Redirect-Reason", "auto add portalalis");
response.Redirect(app.Request.Url.ToString(), true);
}
}
Expand Down Expand Up @@ -451,7 +452,7 @@ public void OnBeginRequest(object s, EventArgs e)
{
redirectUrl = redirectAlias + redirectUrl.Substring(checkAlias.Length);
}

app.Response.AppendHeader("X-Redirect-Reason", "alias redirect");
response.AppendHeader("Location", redirectUrl);
}

Expand All @@ -461,9 +462,11 @@ public void OnBeginRequest(object s, EventArgs e)
{
//Target Url
var redirectUrl = portalSettings.ActiveTab.FullUrl;
app.Response.AppendHeader("X-Redirect-Reason", "page url redirect");
if (portalSettings.ActiveTab.PermanentRedirect)
{
//Permanently Redirect

response.StatusCode = 301;
response.AppendHeader("Location", redirectUrl);
}
Expand Down Expand Up @@ -511,6 +514,7 @@ public void OnBeginRequest(object s, EventArgs e)
if (strURL.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase))
{
//redirect to secure connection
app.Response.AppendHeader("X-Redirect-Reason", "redirect to secure");
response.Redirect(strURL, true);
}
else //when switching to an unsecure page, use a clientside redirector to avoid the browser security warning
Expand Down
Loading

0 comments on commit 4c90cd1

Please sign in to comment.