Giter VIP home page Giter VIP logo

skybrud.umbraco.redirects's Introduction

Skybrud Redirects

GitHub license NuGet NuGet Umbraco Marketplace Skybrud.Umbraco.Redirects at packages.limbo.works

Skybrud.Umbraco.Redirects is a redirects manager for Umbraco. The package features a dashboard and property editor that let's users manage inbound redirects from within the Umbraco backoffice.

URLs can be added to redirect to either a content item, media item or a custom URL.

License: MIT License
Umbraco: Umbraco 13
Target Framework: .NET 8



Installation

Umbraco 13

Version 13 of this package supports Umbraco version 13. The package is only available via NuGet. To install the package, you can use either the .NET CLI:

dotnet add package Skybrud.Umbraco.Redirects --version 13.0.4

or the NuGet Package Manager:

Install-Package Skybrud.Umbraco.Redirects -Version 13.0.4

Umbraco 10, 11 and 12
For the Umbraco 10-12 version of this package, see the v4/main branch instead.

Umbraco 9
For the Umbraco 9 version of this package, see the v3/main branch instead.

Umbraco 8
For the Umbraco 8 version of this package, see the v2/main branch instead.

Umbraco 7
For the Umbraco 7 version of this package, see the v1/main branch instead.



Features

  • Global dashboard for listing all redirects. Supports filtering and searching.

  • Property editor that can be added to either a content item or media item to show inbound redirects

  • Package only handles custom redirecs - eg. added manually by an editor. The package will let Umbraco 7.5+ handle redirects for renamed pages

  • Includes a RedirectsService for managing the redirects from your own code



Add-ons



Documentation

skybrud.umbraco.redirects's People

Contributors

abjerner avatar bjarnef avatar callumbwhyte avatar greystate avatar mastrup avatar mlhdevelopment avatar nikcio avatar phyxionnl avatar rasmusfjord avatar rickbutterfield avatar ruant avatar skttl avatar vsilvar avatar wiggee11 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

skybrud.umbraco.redirects's Issues

Failed to install on Umbraco Cloud v7.8.1

Just installed the package in a v7.8.1 on Umbraco Cloud but I'm getting what I assume is a DLL version and or reference error:

Could not load file or assembly 'Skybrud.Umbraco.Redirects' or one of its dependencies. The system cannot find the file specified.

The DLL is in the bin folder, so I'm suspecting it can't load one of its dependencies (as it says).

No pane appears

Thanks for creating this great package, Anders.

  • Installed latest via Nuget (0.3.4) on umbraco 7.5.13.
  • Everything installs and builds.
  • I made the required changes to web.config and dashboard.config

Still no "Redirects" pane appears in backoffice.

  • No errors in console or log.
  • I tried different browser and editing clientdependencies.config to rule out client caching

Have i missed anything? Is Umbraco 7.5.13 ok with v. 0.3.4?

Have a great day

7.6 support?

I'm having trouble getting this to work on Umbraco version 7.6.6.

We have used this package previously on multiple other solutions where it works fine, those however are v 7.5 and lower.

I installed via NuGet, added httpModule, added Dashboard, added redirect /test to a node, but nothing happens. The log file does not reveal anything either.

Are there any issues in using this on 7.6?

Add automatic migration to v2

I've just upgraded a site from Umbraco 7 to 8 and updated this package to v2. As the SkybrudRedirects table schema is alterned, none of the redirects worked and neither was adding new redirects from the backoffice (because of SQL errors).

It would be nice if this table was automatically migrated as part of the v1 to v2 update. I've now done this with the following SQL script, so it can at least be manually migrated (feel free to add this to the documentation):

BEGIN TRANSACTION;

-- Rename existing table and remove primary key
EXEC sp_rename 'SkybrudRedirects', 'SkybrudRedirectsV7';
ALTER TABLE [SkybrudRedirectsV7] DROP CONSTRAINT [PK_SkybrudRedirects];

-- Optionally delete existing migration, so table can be re-created (make sure to run Umbraco after this)
DELETE FROM [umbracoKeyValue] WHERE [key] = 'Umbraco.Core.Upgrader.State+Skybrud.Umbraco.Redirects' AND [value] = '2.0.0-alpha001';

-- Migrate redirects
SET IDENTITY_INSERT [SkybrudRedirects] ON;
INSERT INTO [SkybrudRedirects] (
	[Id],
	[Key],
	[RootId],
	[RootKey],
	[Url],
	[QueryString],
	[DestinationType],
	[DestinationId],
	[DestinationKey],
	[DestinationUrl],
	[Created],
	[Updated],
	[IsPermanent],
	[IsRegex],
	[ForwardQueryString]
) SELECT
	[RedirectId],
	[RedirectUniqueId],
	[RootNodeId],
	-- RootKey
	CASE WHEN [RootNodeId] = 0 THEN '00000000-0000-0000-0000-000000000000' ELSE (SELECT [uniqueId] FROM [umbracoNode] WHERE [id] = [RootNodeId]) END,
	[Url],
	[QueryString],
	[LinkMode],
	[LinkId],
	-- DestionationKey
	CASE WHEN [LinkId] = 0 THEN '00000000-0000-0000-0000-000000000000' ELSE (SELECT [uniqueId] FROM [umbracoNode] WHERE [id] = [LinkId]) END,
	[LinkUrl],
	DATEADD(S, [Created], '1970-01-01'),
	DATEADD(S, [Updated], '1970-01-01'),
	[IsPermanent],
	[IsRegex],
	[ForwardQueryString]
FROM 
	[SkybrudRedirectsV7];

SET IDENTITY_INSERT [SkybrudRedirects] OFF;

-- Show migrated redirects and remove old table
SELECT * FROM SkybrudRedirects;
DROP TABLE [SkybrudRedirectsV7];

COMMIT TRANSACTION;

Research forced redirects

For a number of different reasons, it could make sense to support forced redirects - that is redirects that still works even when the server responds with something other than a 404 status code.

Forced redirects will however mean that the underlying HTTP module will have to look at all server responses, which could affect performance - so this needs to be done right.

.aspx bliver sorteret fra

På danishcrown.dk oplever vi, at .aspx bliver sorteret fra, når man opretter et nyt redirect (som indeholder .aspx). Pt. løser vi problemet ved at tilføje det manuelt i databasen efterfølgende.

Unable to add redirects to media types File and Image in umbraco 8.1.2

When I add the property editor "Skybrud Redirect - Inbound redirects" to Media Type file and Image in Umbraco 8.1.2 - the property editor does not show up when items of these types are added.

The content dashboard "Redirects" does show up and I can manually enter media file redirects there. e.g. /catalog will redirect to /media/l2hpnd4k/catalog.pdf

Ignore query string on original URL

When the original URL contains a query string, e.g. /bad-url?cookie=yes and a redirect exists for /bad-url, it doesn't match. Only when the option 'Forward query string' is enabled, the redirect kicks in (although it keeps the unnecessary query string)...

I would expect the redirect would work anyway, because anyone could just add a query string to the bad/old URL (some tools do this, e.g. link shortners, social media, Google ads).

Multilingual site

Hello,
I have a multilingual site (3 for the moment).

I can create redirection with my default / mandatory language but I didn't find a way to create a redirection for the 2 other.

Did I miss something?

I try a lot of different way, say me if you want the list.

Javascript error when using inbound redirect property editor in back office

Hi, this is using the alpha004 release, on Umbraco 8.1.4

Simple functionality from the dashboard seems to work fine. Thank you for this project.

Bug:

  • I added the Inbound redirect property editor to a composition I am using on all my pages and saved.
  • Go into Content and open that page.
  • The property editor does not appear, following javascript error in console:

image

angular.js?cdv=1194169033:15536 Error: [$injector:unpr] Unknown provider: dialogServiceProvider <- dialogService <- SkybrudUmbracoRedirects.PropertyEditor.Controller https://errors.angularjs.org/1.7.5/$injector/unpr?p0=dialogServiceProvider%20%3C-%20dialogService%20%3C-%20SkybrudUmbracoRedirects.PropertyEditor.Controller at angular.js?cdv=1194169033:138 at angular.js?cdv=1194169033:4905 at Object.getService [as get] (angular.js?cdv=1194169033:5065) at angular.js?cdv=1194169033:4910 at getService (angular.js?cdv=1194169033:5065) at injectionArgs (angular.js?cdv=1194169033:5090) at Object.invoke (angular.js?cdv=1194169033:5114) at $controllerInit (angular.js?cdv=1194169033:11673) at nodeLinkFn (angular.js?cdv=1194169033:10486) at compositeLinkFn (angular.js?cdv=1194169033:9801) "<div ng-include="propertyEditorView" class="ng-scope">"

v2.0.0 is missing declared dependency on Umbraco 8 in NuGet package

I just installed Skybrud.Umbraco.Redirects 2.0.0 via NuGet Package Manager (GUI) in Visual Studio 2019, on an Umbraco 7.15.3 project. Now, I get a YSOD:

Could not load file or assembly 'Umbraco.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

After simply uninstalling Skybrud.Umbraco.Redirects 2.0.0 via NuGet Package Manager, Umbraco runs fine.

Redirects are redirecting to parent node url instead of selected node

We are using the package on a project and we are very happy with it 😁👍

Mostly the redirects are working, but we have a few which doesn't seem to work, e.g. the following:

image

image

It should redirect /maerker1/moxalole to /maerker/moxalole, but it seems to stay on this page: /maerker1/moxalole

I have disabled any other redirects in web.config and contentfinders just to be sure, but it doesn't seem to fix the issue.

On live environment the redirect actually seems to redirect to its page node although it is the same details as above.

/maerker1/moxalole -> /maerker1

Improve the site filter

With the site filter introduced in v0.2.5, there are currently no way to only show redirects where a site hasn't been specified. You can either choose to show all redirects, or redirects for a specified site.

Ideally there should also be an option for Not specified.

Disable Angular dirty checking for the dashboard and property editor

Angular and Umbraco will automatically do dirty checking (whether a field has an unsaved value) for dropdowns, input fields and similar since these are located within a form element. With the current dirty checking, user might see a notification like this (in Danish):

image

While the package itself handles saving and updating redirects, and some input fields are only used for filters, we really don't need Umbraco to handle dirty checking.

Updated existing redirect

Anders,

I created a new redirect and the destination was an umbraco page. I then went to edit it and set it to an external page however I cannot do that the url part is now fixed. Only thing I can do is delete and recreate.

Am I missing something?

Regards

Ismail

Manual URL entry edit broken

After inserting a static redirect entry, editing it afterwards will result in an empty Original URL field.
Both the Original URL and the Destination are shown in the list. Searching for the original url works,
and the redirect works.

Adding for example:
Original URL: /some-path/some-page/
Destination: https://www.site.com/new-page/

When editing the entry the Desination is still filled in though,
just the Original field is empty.

Fresh install, adding a redirect fails with error in Danish

Just installed this cool package. After following the setup guide, I attempted to add a redirect and received an untranslated error when attempting to submit:

Oprettelse fejlede: Grundet en fejl på serveren kunne dit redirect ikke oprettes.
Translation - Creation failed: Due to an error on the server, your redirect could not be created.

This is on my localhost and I couldn't find any more verbose errors in the Umbraco log nor Events Viewer, so I'm not sure what the issue is. I did notice that I'm unable to select any sites from the site dropdown, even though I have a single site setup. Are there any extra settings that I'm missing?

Unable to load redirects

I installed the package v.0.2.2 via NuGet and added the dashboard.

After refreshing browser the dashboard is added, but I get the following error:
image

Tested in Umbraco version 7.5.8 and on Umbraco Cloud, but local - so the db is SQL CE.

Keep design consistent with Umbraco backoffice

The user experience could be streamlined if the listview matched the Umbraco Redirect URL Management.
I was thinking of:

  • moving the redirect icon
  • renaming the "destination" column to "redirected to"
  • Color the "delete" button and rename it to "remove"

Updated view

And this is how the Umbraco Redirect URL Management looks:
Umbraco redirect url management

Could this be an idea?

Feature request: bulk import

We like using your redirects package and it has pretty much become the standard with all our Umbraco projects.
But one feature we would like to see is a bulk import to be able to import a large list of redirects in one go. Often the redirects 'required' for a site are determined by the SEO team, who then provide us with a spreadsheet of old and new URLs. If there was a way to import those straight into the dashboard, it would be a real time saver.

So we're thinking the functionality should allow you to upload a CSV or XLSX file which contains the following columns:

  • Old URL (relative)
  • New URL (relative or absolute if it's an external URL)
  • Type (which would be Content, Media or URL)

Apart from selecting the file, the user would also select for which site (or All Sites) they want to upload the redirects, and whether they want to override existing redirects or skip if a redirect already exists.

When clicking Upload it would then parse the CSV/XLSX and then loop through each entry and add or update (if set to update) the RedirectItemRow to the database. This would also involve looking up the Umbraco node IDs of each new URL (if it's Content or Media) since that wouldn't be something the SEO team would look up.

As I said, it's something we would be very keen to see, and we're thinking of adding this ourselves through a PR. But before starting the work we wanted to check first if this functionality would be useful to other people as well, and if we need to think of any other functionality as part of this.

Zip file is missing a dependent dll: Skybrud.WebApi.Json

If I download the zip file from the Releases on Github, then copy the files into a new download of Umbraco I get an error page on load:

Server Error in '/' Application.

Could not load file or assembly 'Skybrud.WebApi.Json, Version=1.0.3.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

This is a bit of a pain because the releases of 'Skybrud.WebApi.Json' doesn't have a zip download so I have to download the source and build it to get the dll.

Generally, I'd use nuget to pull all this in, but I'm just doing some quick testing.

Adding redirect to new media URL still saves old URL

Having good image URLs/file names helps with SEO, so an editor is re-uploading images with better filenames from the Umbraco back-office (to the same media entity - I haven't found another built-in way to do this).

Instead of having the editor also manually add the redirect (with query string forwarding on, so ImageProcessor options are preserved), I created an event handler to do this:

protected void MediaService_Saving(IMediaService sender, SaveEventArgs<IMedia> e)
{
	var renamedMedia = e.SavedEntities.Where(m => !m.IsNewEntity() && m.IsPropertyDirty(Constants.Conventions.Media.File)).ToList();
	if (renamedMedia.Count > 0)
	{
		var repository = new RedirectsRepository();
		var logger = ApplicationContext.Current.ProfilingLogger.Logger;

		foreach (var media in renamedMedia)
		{
			try
			{
				var cachedMedia = UmbracoContext.Current.MediaCache.GetById(media.Id);
				var url = media.GetUrl(Constants.Conventions.Media.File, logger);

				// Save new redirect
				var redirect = repository.AddRedirect(0, cachedMedia.Url, new RedirectLinkItem(media.Id, media.Name, url, RedirectLinkMode.Media), true, false, true);
				logger.Info(this.GetType(), "Redirect automatically added for media {0} from {1} to {2}", () => media.Id, () => redirect.Url, () => redirect.LinkUrl);
			}
			catch (RedirectsException ex)
			{
				logger.WarnWithException(this.GetType(), "Redirect could not be automatically added for media {0}", ex, () => media.Id);
			}
		}
	}
}

Instead of saving the url passed to RedirectLinkItem, the media URL is saved... This also causes a redirect loop, since the source and destination URLs are the same and the redirect module also doesn't use the new URL when doing the redirect.

Setting the id to 0 and the RedirectLinkMode to Url fixes this, but you loose the ability to lookup redirects for that media item.

Adding redirect for urls including index.php

I've moved an old Joomla site over to Umbraco.
And I'm trying to do some redirects.
When I try to enter https://domain.com/index.php/contact-us I get and error saying:
The specified URL is not valid. A valid URL should look like /page or /page/subpage.

If I go to any of these old index.php URL's I do get a 404 response back.

Any tricks to make this work?

Installing nuget breaks the project

When installing the nuget package I get the following error:
Umbraco version is 8.2.0
Redirect version is 2.0 (latest version on nuget)

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

[InvalidOperationException: Unable to resolve type: Skybrud.Umbraco.Redirects.Routing.RedirectsInjectedModule, service name: ]    LightInject.ServiceContainer.CreateDelegate(Type serviceType, String serviceName, Boolean throwError) +382    LightInject.ServiceContainer.CreateDefaultDelegate(Type serviceType, Boolean throwError) +78    LightInject.ServiceContainer.GetInstance(Type serviceType) +152    Umbraco.Core.Composing.LightInject.LightInjectContainer.GetInstance(Type type) +10    Umbraco.Core.FactoryExtensions.GetInstance(IFactory factory) +56    Umbraco.Web.Composing.ModuleInjector`1.Init(HttpApplication context) +163    System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +523    System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +176    System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +220    System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +303  [HttpException (0x80004005): Unable to resolve type: Skybrud.Umbraco.Redirects.Routing.RedirectsInjectedModule, service name: ]    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +659    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +89    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +189

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4001.0

If I refer to the RedirectsInjectedModule in code it is there. So something with the order of loading dependancies?

A new property editor listing the redirects of an entire site

The package already has a dashboard for viewing all redirects across the Umbraco installation as well as a property editor for listing the redirects pointing to a given content or media item.

It would also be useful to have a property editor listing the redirects for which the current site (based on domains and root nodes) have been selected.

Site-specific redirects for static files not working

When you try to add a redirect for a static file, for example from http://www.mysite.com/old.pdf to http://www.mysite.com/my-new-page, it will not work when you select a specific site from the dropdown.

Since it will go through the HttpModule without an Umbraco context it will fail to get the domain assigned for the current request, and it will default to get the redirects which are set to 'All sites' (ID = 0).
So the example redirect mentioned above does work when I set it to 'All sites', but not when I select the specific site from the dropdown.

I noticed a comment in the code that mentioned a TODO item to add code which retrieves the domain using the DomainService. I've now added this in and created a pull request for this.

Adding in this piece of code will mean the correct IDomain object is retrieved for the current request, and the site-specific redirect will now execute as expected.

Unable to resolve type: Skybrud.Umbraco.Redirects.Routing.RedirectsInjectedModule

This packages contains an HTTP module that uses dependency injection. The module is registered via the following composer in Umbraco:

public class RedirectsComposer : IUserComposer {

    public void Compose(Composition composition) {
        composition.Register<IRedirectsService, RedirectsService>();
        composition.Register<RedirectsInjectedModule, RedirectsInjectedModule>(); 
    }

 }

When trying to upgrade Umbraco, the following exception is thown:

[InvalidOperationException: Unable to resolve type: Skybrud.Umbraco.Redirects.Routing.RedirectsInjectedModule, service name: ]
   LightInject.ServiceContainer.CreateDelegate(Type serviceType, String serviceName, Boolean throwError) in C:\projects\lightinject\src\LightInject\LightInject.cs:4754
   LightInject.ServiceContainer.CreateDefaultDelegate(Type serviceType, Boolean throwError) in C:\projects\lightinject\src\LightInject\LightInject.cs:4705
   LightInject.ServiceContainer.GetInstance(Type serviceType) in C:\projects\lightinject\src\LightInject\LightInject.cs:3437
   Umbraco.Core.FactoryExtensions.GetInstance(IFactory factory) +56
   Umbraco.Web.Composing.ModuleInjector`1.Init(HttpApplication context) +295
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +581
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +168
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +277
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369

[HttpException (0x80004005): Unable to resolve type: Skybrud.Umbraco.Redirects.Routing.RedirectsInjectedModule, service name: ]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +714

Introduce cache layer

The HTTP module will make a handful of SQL queries per request (think it's four at worst). With a site that receives many 404 request, this may affect performance of the database and site.

For a number of reasons, it may be ideal to have a cache layer in front of the database. A cache layer will reduce the amount of calls to the database considerably, and also allow us to do new things - eg. adding support for forced redirects.

Improve localization

There are still a few labels that are either hardcoded in English or Danish - eg. most notifications are in Danish.

Add database indexes

The SkybrudRedirects table should get some database indexes, as retrieving rows currently scans the whole table and that can take quite some time, especially when a lot of redirects are added...

The built-in Umbraco umbracoRedirectsUrl table indexes a hash of the URL, together with the resulting content/node key, culture and creation date. This ensures the index isn't unneccesary large and sorting on most recently added redirect can also be done efficiently within the database.

Nuget Transforms

I noticed the NuGet package install requires manual configuration but this could be done using transforms.

Pull request incoming but wanted to raise an issue first

Matt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.