410 not cleared when a page is republished
Myster opened this issue · 4 comments
Myster commented
I'm adding this in case this project gets un-abondoned. :-)
When a page is republished it gets a 410 record.
If republished at a different url (parent renamed) it is not redirected
Myster commented
I did this in my code (works for me) perhaps should be pulled into the project?
public class ContentTrackerHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication,
ApplicationContext applicationContext)
{
ContentService.Published += Convert410To301Records;
}
private void Convert410To301Records(IPublishingStrategy sender, PublishEventArgs<IContent> args)
{
var database = ApplicationContext.Current.DatabaseContext.Database;
foreach (var item in args.PublishedEntities)
{
database.Execute(Sql.Builder
.Append("UPDATE icUrlTracker " +
"SET RedirectHttpCode = 301 " +
"WHERE RedirectHttpCode = 410 " +
"AND RedirectNodeId = @0", item.Id));
}
}
}
daniel-chenery commented
@Myster Thanks, I'll take a look. If a page exists though, it should never hit the URL Tracker AFAIK. It will only run it's code when a 404 is hit.
I'll confirm this though and make updates if required.
What sort of server is this on? Local, Shared, Azure?
Myster commented
Local & shared server.
The issue is when you unpublish, then move, then republish
daniel-chenery commented
Fixed with 3.14