- Issue created by @divya.lakshman
- 🇮🇳India Yogesh Kambari
I am able to reproduce similar kind of scenario.
Like i have created two nodes with URL alias as "/redirect-1" and "/redirect-2". Now i have added redirect rule in which i have source as "/redirect-2" and destination as "/redirect-1".
Now if i hit "/redirect-2" then it doesn't get redirected to "/redirect-1".
It looks like we need to add node id ('node/nid') in redirection rule (for source node which are having some url alias).
If it is the same scenario you are facing then requesting you to try with adding node id "node/nid" in redirect rule. Though i tried below work around on my local and it works for me.Added below line of code in file : /src/EventSubscriber/RedirectRequestSubscriber.php
@@ -136,6 +136,7 @@ class RedirectRequestSubscriber implements EventSubscriberInterface {
// Do the inbound processing so that for example language prefixes are
// removed.
$path = $this->pathProcessor->processInbound($request->getPathInfo(), $request);
+ $path = \Drupal::service('path_alias.manager')->getAliasByPath($path);
}
$path = trim($path, '/'); - 🇬🇧United Kingdom Michelle-Buckby
Seeing the same issue, the code added in #2 inside RedirectRequestSubscriber.php also working locally for me.
Adding a node id may not be good for a client so I think amending the code instead is the way forward.. with a patch? - 🇧🇷Brazil brandonlira
I've tested the patch in #4 with Drupal 10.1.6 and Redirect 8.x-1.9.It resolves the issue for me.
- last update
over 1 year ago 55 pass, 4 fail - 🇺🇸United States chambers
I tested this patch locally and it causes a redirect loop on the homepage and crashes it. It did fix the redirect but not usable due to the loop.
- First commit to issue fork.
- last update
over 1 year ago 60 pass, 1 fail - 🇮🇳India sumit-k
verified the provided patch, and it is functioning as expected in my local environment. Raising MR !80 to fix the issues related to test cases effectively.
- 🇬🇧United Kingdom Michelle-Buckby
I've since seen this patch causing a redirect loop, where a redirect alias is pointing to itself.
It works in all other cases but maybe because of the redirect loop, this is not ready for a MR?Also, I just took the code already mention in comment #2 and placed it in a patch..
it may not be the best approach? - 🇬🇧United Kingdom welly
I've been experiencing similar issues and have tried the patch. So far, so good. But will need more testing. I'm not sure how Redirect currently handles redirects pointing to itself but a redirect loop sounds like it would be the expected behaviour to me. Before applying the patch, what happened in that example? Did it resolve itself or something else?
- 🇬🇧United Kingdom welly
I'm going to put this into RTBC because I'm not experiencing any redirect loops and we've fairly thoroughly tested the patch in a staging environment with no experience of redirect loops. And in fact, trying to create a redirect to itself the module flags this and gives a error message.
- Status changed to RTBC
over 1 year ago 2:35pm 1 March 2024 - 🇬🇧United Kingdom welly
Trying again to change status - it didn't change before!
- 🇬🇧United Kingdom steven jones
- 🇬🇧United Kingdom welly
@Steven Jones, that was the patch in #4 I tested and have been using. Cheers!
- Status changed to Needs work
over 1 year ago 9:19pm 6 March 2024 - 🇬🇧United Kingdom welly
Have been experiencing redirect loops on a site we're using the patch with so back to "needs work" and I'll try and have a look at this myself.
- 🇬🇧United Kingdom endrukk
#4 is causing `Service unavailable` errors all over my site. Also doesn't comply with coding standards and `$path` is assigned a value twice.
- 🇳🇱Netherlands Summit
Hi, I experience this issues also, any progress please? Greetings,
- 🇫🇷France pogfra
Hi,
i'am facing the same problem and after some debug i figured that the findMatchingRedirect($source_path, array $query = [], $language = Language::LANGCODE_NOT_SPECIFIED) method doesn't able to get the right hash from database in some cases.
The source_path passing to the method is a /node/nid but in database the redirect_source__path is an alias without langcode.
The language used to generate array of hashes to query database is the current of the redirect_source__path or und but never the other so an "en" source to a "fr" destination can't work.
And The Url object use to the redirection once the right redirection is found is from the original request and not from redirection.
Maybe i'am wrong but for me the language of the redirection is the language of the destination but it seem to be these of the origin.
No time to investigate more but there is a dirty quick test patch which seem to fix it in my tests cases
- 🇨🇦Canada awasson
Experiencing the same issue on a Drupal 10 site.
#20 has fixed the issue
No loop problem detected yet.
- 🇫🇷France skoubi
I've tested the patch #20 on my production Drupal 10 site as i was experiencing the same issue, and it throws an error on some old links!
The error in my case is: Not Found. The requested URL "/core/misc/modernizr-additional-tests.js" was not found on this server.
Removing the patch, this error disappear on the old links that are not redirecting. Any updates on it ? - 🇺🇸United States philip_stier Denver, Colorado
I am confirming the same as @skoubi. Patch on #20 worked to get new redirects functioning again, but therein broke old redirects.
Drupal 11.1.7
Redirect 1.11
Pathauto 1.13 Hi,
We just deployed updates to our site.
Drupal 10.4.6
PathAuto 8.x-1.12
Redirect 8.x-1.9One of the updates was to patch redirect with #20.
Redirects where both pages exist in the system work.
We are encountering redirect loops however.
Now redirects where the FROM page does not exist (its been removed) but TO pages do exist no longer work. Pages that we no longer need but we keep a redirect in place for analytics purposes.
A work around for now would be to re-create the page we removed and update the redirect. This is not always feasible however.
I am recommending for now to keep #20 patch installed and not to revert because at least the vast majority of our redirects will function.
I am happy to give any additional information that might be needed such as we host our site on Pantheon, not sure if this matters.
Hope this helps.
Dave
I found another ticket and read and followed the recommendations from that ticket. I did remove patch #20 and added the patch from this ticket https://www.drupal.org/project/redirect/issues/2879648 🐛 Redirects from aliased paths aren't triggered Needs review .
I implemented the recommendations from https://www.drupal.org/project/redirect/issues/2879648 🐛 Redirects from aliased paths aren't triggered Needs review #147.
This has resolved our redirect challenges.
Hello,
I got issues using the patch #20 cause of the ltrim function.
In case you don't have the current language into the url you are redirecting from, the ltrim was only removing some characters if, by misfortune, your url is starting with same letters as the current language.
For example, if your are redirecting from "excellent-news-article" and your current language is english ('EN'), the code was looking into the database table for "xcellent-news-article" as redirect_source__path (once trim of / and ltrim of current language applied).
Find attached a patch without this ltrim line.