Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site specific redirect only works for unique domains #191

Open
bjarnef opened this issue Nov 28, 2023 · 1 comment
Open

Site specific redirect only works for unique domains #191

bjarnef opened this issue Nov 28, 2023 · 1 comment
Labels
type/bug Something isn't working

Comments

@bjarnef
Copy link
Contributor

bjarnef commented Nov 28, 2023

Which version of Skybrud Redirects are you using? (Please write the exact version, example: 4.0.8)

4.0.17

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

12.2.0

Bug description

We have a multi-site project with the following sites

Site A (English) domain.com
Site B (Danish) domain.com/da
Site C (Norwegian) domain.com/no
Site D (Swedish) domain.com/se
etc.

If we added a site specific redirect for e.g. Norwegian site e.g. /no/test?hello=world this didn't have any effect, but if moved to main site /test?hello=world it did work.

I suspect it does work with unique domains e.g. if Norwegian site has domain domain.no or no.domain.com and it is an issue because it probably match first site with domain (but the site id doesn't match), so no match was found and redirect didn't have any effect.

While on Site A it find the match because it is first domain with site/root id found, which match the site id on the redirect.

Not sure if the order of the sites matter or it depends on the order the domains was created in Umbraco.

@bjarnef bjarnef added the type/bug Something isn't working label Nov 28, 2023
@abjerner
Copy link
Member

Hi @bjarnef

Can you run this partial Razor view somewhere in the solution? And if so, what does it return?

@using Umbraco.Cms.Core.Services
@using Skybrud.Umbraco.Redirects.Services
@using Umbraco.Cms.Core.Routing
@using Skybrud.Umbraco.Redirects.Models
@inject IDomainService DomainsService
@inject IRedirectsService RedirectsService

@{

    Uri uri = new Uri("https://domain.com/no/test");

    if (DomainUtils.TryGetDomain(DomainsService, uri, out Domain? domain)) {
        <pre>Yay -> @domain.Name</pre>
    } else {
        <pre>Bah</pre>
    }

    <hr />

    IRedirect? redirect = RedirectsService.GetRedirectByUri(uri);

    if (redirect is null) {
        <em>Not found...</em>
        return;
    }

    <pre>@redirect.Id -> @redirect.Key -> @redirect.Destination.Url</pre>

}

This should roughly align with the logic in the middleware. When I test this locally, it does find both the domain and my test redirect.

My domain configuration looks like this:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants