diff --git a/src/Umbraco.Core/Configuration/UmbracoVersion.cs b/src/Umbraco.Core/Configuration/UmbracoVersion.cs
index 762d3da59c..7fc03df6eb 100644
--- a/src/Umbraco.Core/Configuration/UmbracoVersion.cs
+++ b/src/Umbraco.Core/Configuration/UmbracoVersion.cs
@@ -24,7 +24,7 @@ namespace Umbraco.Core.Configuration
/// Gets the version comment (like beta or RC).
///
/// The version comment.
- public static string CurrentComment { get { return ""; } }
+ public static string CurrentComment { get { return "alpha002"; } }
// Get the version of the umbraco.dll by looking at a class in that dll
// Had to do it like this due to medium trust issues, see: http://haacked.com/archive/2010/11/04/assembly-location-and-medium-trust.aspx
diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenFiveZero/AddRedirectUrlTable.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenFiveZero/AddRedirectUrlTable.cs
index 43c2da780b..56e423ebaf 100644
--- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenFiveZero/AddRedirectUrlTable.cs
+++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenFiveZero/AddRedirectUrlTable.cs
@@ -24,13 +24,14 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenFiveZer
.WithColumn("createDateUtc").AsDateTime().NotNullable()
.WithColumn("url").AsString(2048).NotNullable();
- Create.PrimaryKey("PK_umbracoRedirectUrl").OnTable("umbracoRedirectUrl").Columns(new[] { "id" });
+ //Create.PrimaryKey("PK_umbracoRedirectUrl").OnTable("umbracoRedirectUrl").Columns(new[] { "id" });
Create.Index("IX_umbracoRedirectUrl").OnTable("umbracoRedirectUrl")
.OnColumn("url")
.Ascending()
.OnColumn("createDateUtc")
- .Ascending();
+ .Ascending()
+ .WithOptions().NonClustered();
}
public override void Down()
diff --git a/src/Umbraco.Core/Services/IRedirectUrlService.cs b/src/Umbraco.Core/Services/IRedirectUrlService.cs
index 6dd36d438c..e7c60c7d5a 100644
--- a/src/Umbraco.Core/Services/IRedirectUrlService.cs
+++ b/src/Umbraco.Core/Services/IRedirectUrlService.cs
@@ -7,7 +7,7 @@ namespace Umbraco.Core.Services
{
void Save(IRedirectUrl redirectUrl);
- void DeleteContentUrls(int contentId);
+ void DeleteContentRedirectUrls(int contentId);
void Delete(IRedirectUrl redirectUrl);
@@ -15,12 +15,12 @@ namespace Umbraco.Core.Services
void DeleteAll();
- IRedirectUrl GetMostRecentRule(string url);
+ IRedirectUrl GetMostRecentRedirectUrl(string url);
- IEnumerable GetContentUrls(int contentId);
+ IEnumerable GetContentRedirectUrls(int contentId);
- IEnumerable GetAllUrls(long pageIndex, int pageSize, out long total);
+ IEnumerable GetAllRedirectUrls(long pageIndex, int pageSize, out long total);
- IEnumerable GetAllUrls(int rootContentId, long pageIndex, int pageSize, out long total);
+ IEnumerable GetAllRedirectUrls(int rootContentId, long pageIndex, int pageSize, out long total);
}
}
diff --git a/src/Umbraco.Core/Services/RedirectUrlService.cs b/src/Umbraco.Core/Services/RedirectUrlService.cs
index c2879fac24..9316e00b6f 100644
--- a/src/Umbraco.Core/Services/RedirectUrlService.cs
+++ b/src/Umbraco.Core/Services/RedirectUrlService.cs
@@ -47,7 +47,7 @@ namespace Umbraco.Core.Services
}
}
- public void DeleteContentUrls(int contentId)
+ public void DeleteContentRedirectUrls(int contentId)
{
using (var uow = UowProvider.GetUnitOfWork())
using (var repo = RepositoryFactory.CreateRedirectUrlRepository(uow))
@@ -67,7 +67,7 @@ namespace Umbraco.Core.Services
}
}
- public IRedirectUrl GetMostRecentRule(string url)
+ public IRedirectUrl GetMostRecentRedirectUrl(string url)
{
using (var uow = UowProvider.GetUnitOfWork())
using (var repo = RepositoryFactory.CreateRedirectUrlRepository(uow))
@@ -78,7 +78,7 @@ namespace Umbraco.Core.Services
}
}
- public IEnumerable GetContentUrls(int contentId)
+ public IEnumerable GetContentRedirectUrls(int contentId)
{
using (var uow = UowProvider.GetUnitOfWork())
using (var repo = RepositoryFactory.CreateRedirectUrlRepository(uow))
@@ -89,7 +89,7 @@ namespace Umbraco.Core.Services
}
}
- public IEnumerable GetAllUrls(long pageIndex, int pageSize, out long total)
+ public IEnumerable GetAllRedirectUrls(long pageIndex, int pageSize, out long total)
{
using (var uow = UowProvider.GetUnitOfWork())
using (var repo = RepositoryFactory.CreateRedirectUrlRepository(uow))
@@ -100,7 +100,7 @@ namespace Umbraco.Core.Services
}
}
- public IEnumerable GetAllUrls(int rootContentId, long pageIndex, int pageSize, out long total)
+ public IEnumerable GetAllRedirectUrls(int rootContentId, long pageIndex, int pageSize, out long total)
{
using (var uow = UowProvider.GetUnitOfWork())
using (var repo = RepositoryFactory.CreateRedirectUrlRepository(uow))
diff --git a/src/Umbraco.Web/Routing/ContentFinderByRedirectUrl.cs b/src/Umbraco.Web/Routing/ContentFinderByRedirectUrl.cs
index 0e112fdbe9..aa68922f21 100644
--- a/src/Umbraco.Web/Routing/ContentFinderByRedirectUrl.cs
+++ b/src/Umbraco.Web/Routing/ContentFinderByRedirectUrl.cs
@@ -1,8 +1,8 @@
-namespace Umbraco.Web.Routing
-{
- using Umbraco.Core;
- using Umbraco.Core.Logging;
+using Umbraco.Core;
+using Umbraco.Core.Logging;
+namespace Umbraco.Web.Routing
+{
///
/// Provides an implementation of that handles page url rewrites
/// that are stored when moving, saving, or deleting a node.
@@ -20,48 +20,32 @@
/// Optionally, can also assign the template or anything else on the document request, although that is not required.
public bool TryFindContent(PublishedContentRequest contentRequest)
{
- string route;
- if (contentRequest.HasDomain)
+ var route = contentRequest.HasDomain
+ ? contentRequest.UmbracoDomain.RootContentId + DomainHelper.PathRelativeToDomain(contentRequest.DomainUri, contentRequest.Uri.GetAbsolutePathDecoded())
+ : contentRequest.Uri.GetAbsolutePathDecoded();
+
+ var service = contentRequest.RoutingContext.UmbracoContext.Application.Services.RedirectUrlService;
+ var redirectUrl = service.GetMostRecentRedirectUrl(route);
+
+ if (redirectUrl == null)
{
- route = contentRequest.UmbracoDomain.RootContentId + DomainHelper.PathRelativeToDomain(contentRequest.DomainUri, contentRequest.Uri.GetAbsolutePathDecoded());
- }
- else
- {
- route = contentRequest.Uri.GetAbsolutePathDecoded();
+ LogHelper.Debug("No match for route: \"{0}\".", () => route);
+ return false;
}
- return this.FindContent(contentRequest, route);
- }
-
- ///
- /// Tries to find an Umbraco document for a PublishedContentRequest and a route.
- ///
- /// The document request.
- /// The route.
- /// True if a redirect is to take place, otherwise; false.
- protected bool FindContent(PublishedContentRequest contentRequest, string route)
- {
- var rule = contentRequest.RoutingContext
- .UmbracoContext.Application.Services
- .RedirectUrlService.GetMostRecentRule(route);
-
- if (rule != null)
+ var content = contentRequest.RoutingContext.UmbracoContext.ContentCache.GetById(redirectUrl.ContentId);
+ var url = content == null ? "#" : content.Url;
+ if (url.StartsWith("#"))
{
- var content = contentRequest.RoutingContext.UmbracoContext.ContentCache.GetById(rule.ContentId);
- if (content != null)
- {
- var url = content.Url;
- if (url != "#")
- {
- contentRequest.SetRedirectPermanent(url);
- LogHelper.Debug("Got content, id={0}", () => content.Id);
- return true;
- }
- }
+ LogHelper.Debug("Route \"{0}\" matches content {1} which has no url.",
+ () => route, () => redirectUrl.ContentId);
+ return false;
}
- LogHelper.Debug("No match for the url: {0}.", () => route);
- return false;
+ LogHelper.Debug("Route \"{0}\" matches content {1} with url \"{2}\", redirecting.",
+ () => route, () => content.Id, () => url);
+ contentRequest.SetRedirectPermanent(url);
+ return true;
}
}
}
diff --git a/src/Umbraco.Web/WebBootManager.cs b/src/Umbraco.Web/WebBootManager.cs
index 93928d0867..06f47abe81 100644
--- a/src/Umbraco.Web/WebBootManager.cs
+++ b/src/Umbraco.Web/WebBootManager.cs
@@ -514,6 +514,8 @@ namespace Umbraco.Web
//typeof (ContentFinderByProfile),
//typeof (ContentFinderByUrlAlias),
+ typeof(ContentFinderByRedirectUrl), // fixme - position?
+
// implement INotFoundHandler support... remove once we get rid of it
typeof(ContentFinderByNotFoundHandlers)
);