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

Multi-site setup issues #241

Open
vandres opened this issue Aug 5, 2022 · 6 comments
Open

Multi-site setup issues #241

vandres opened this issue Aug 5, 2022 · 6 comments
Labels
question Further information is requested

Comments

@vandres
Copy link

vandres commented Aug 5, 2022

Question

I am trying to get the plugin working with my multi-site setup. We have 6 different sites, with 2 different domains and 2 languages.

image

This is working (RegEx).

image

But when I auto generate redirects "when entry urls change", it's generated like this.

image

This is not working, because it doesn't respect the site path.

If I change it manually to this, it is working again.

image

Am I missing something in my setup? Would it be possible, to allow configuring "exactmatch" to "regexmatch" for auto generated redirects?

@vandres vandres added the question Further information is requested label Aug 5, 2022
@khalwat
Copy link
Contributor

khalwat commented Aug 5, 2022

Probably you need to use Entry Redirects URL Match Type set to Full URL

@khalwat khalwat closed this as completed Aug 5, 2022
@vandres
Copy link
Author

vandres commented Aug 6, 2022

@khalwat Thanks for the response. When creating a new rule from the 404 dashboard, neither are respected, right? Neither the mentioned setting, nor the site url. How to make this more convenient for the non-technical users?

grafik

@khalwat
Copy link
Contributor

khalwat commented Aug 7, 2022

Right, perhaps that should be set as the default for new redirects that are manually created too?

@vandres
Copy link
Author

vandres commented Aug 8, 2022

Sounds good

@vandres
Copy link
Author

vandres commented Oct 5, 2022

For anybody interested. I was able to resolve our setup with the following Event:

        Event::on(Redirects::class, Redirects::EVENT_BEFORE_RESOLVE_REDIRECT, function (ResolveRedirectEvent $event) {
            $site = \Craft::$app->getSites()->currentSite;
            $redirects = Retour::$plugin->redirects->getAllStaticRedirects(null, $site->id);

            foreach ($redirects as $redirect) {
                if ($redirect['redirectMatchType'] !== 'exactmatch') {
                    continue;
                }
                if ($redirect['redirectSrcMatch'] !== 'pathonly') {
                    continue;
                }

                $urlToMatch = rtrim($site->baseUrl, '/') . '/' . ltrim($redirect['redirectSrcUrlParsed'], '/');
                if ($event->fullUrl !== $urlToMatch) {
                    continue;
                }

                $redirectUrl = rtrim($site->baseUrl, '/') . '/' . ltrim($redirect['redirectDestUrl'], '/');
                $event->redirectDestUrl = $redirectUrl;
                break;
            }
        });

@khalwat
Copy link
Contributor

khalwat commented Oct 5, 2022

Ah let me re-open this so I don't miss putting the change in mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants