skybrud / Skybrud.Umbraco.Redirects.Import

Import and export addon for Skybrud.Umbraco.Redirects.
MIT License
7 stars 11 forks source link

Allow URL rediects #7

Closed NISPico closed 1 year ago

NISPico commented 1 year ago

Hey :)

When importing and not having absolute path you get the error, i can see you have an TODO here:

else if (destinationUrl.StartsWith("/")) {
                if (destination == null) {
                    if (TryGetContent(destinationUrl, out IPublishedContent? content)) {
                        destination = content;
                        destinationUrl = content.Url();
                        destinationType = RedirectDestinationType.Content;
                    } else {
                        // TODO: Should this trigger an error, or just create an 'URL' redirect?
                        item.Errors.Add($"No destination found with URL '{destinationUrl}.");
                        return;

Do you plan on ever adding the TODO, so that the redirect is just added as a normal URL redirect?

abjerner commented 1 year ago

@NISPico do you have any examples on situations where'd you need this?

The logic from your example will try to look up content in Umbraco that matches the destination URL. There is a similar check for media.

If neither a matching content or media item is found, this triggers an error. I think this would be the expected result in most situations.

I can see this being a problem if the destination URL refers pages or files that are handled outside of Umbraco - eg. static assets or if you have custom MVC controllers. So right now, the package doesn't support this.

NISPico commented 1 year ago

@abjerner When I'm importing a CSV for a site with mulitple hostnames, i would like to be able to just add "/Support" as the destination, so relative links not the full path which it wants right now. I'm not sure of it's a Umbraco 11 bug, because the content node actually has the url path "/Support" in the url overview.

abjerner commented 1 year ago

Hi @NISPico and sorry for not getting back to you

In your site does have a page with the URL /Support and your imported file has this URL as the destination, the import logic should detect this and create a content redirect - not a URL redirect. If your Umbraco installation has multiple sites, you may however also have to specify a root node.

You can read more about the supported columns here:

https://packages.skybrud.dk/skybrud.umbraco.redirects.import/docs/v4/import/columns/

You haven't specified what version of the package you're using, but seeing this issue was created back in March, there has been a few releases since then, including astable release for v4.0.0. If you're still experiencing issues, does it help upgrading to the newest version?

I'm closing the issue for now, but if there is an issue in the newest version of the package, we can always open the issue again 😉