Accidentally entering the wrong path on a website served from NGINX will not allow for automatic searching or parsing of keys derived from the URL path alias.
As some major hosting companies use NGINX servers, this could be an issue for anyone using Search 404 on those systems.
The problem arises from the following server request on line 26 of search404.module:
if (empty($keys)) {
$keys = \Drupal::request()->server->get('REDIRECT_URL');
}
get('REDIRECT_URL') will only work on Apache web servers. More information here.
I attempted a patch myself, but have had no success with the new Drupal 8 path API. Perhaps someone smarter than me can take a look at this issue?
So far I have tried to make use of the following with no luck as they render the internal path rather than the user's input:
\Drupal::service('path.current')->getPath();
\Drupal::request()->getRequestUri();
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | keys_from_path_do_not_work-2697197-11.patch | 1.04 KB | magi.yv |
Comments
Comment #2
rich_dawson commentedComment #3
heikki commentedThis is not a correct solution, but I used this to pick keys from the url:
This obviously only picks the last segment of the path, but it's enough for my use-case.
You could try this if you are using OR query in search api (or whatever search module you are using).
Comment #4
anish_zyxware commented@heikki
Can you make it as a patch? I don't have an nginx instance right now to test it. So I was postponing it indefinitely.
Comment #5
magi.yv commentedComment #6
magi.yv commented@heikki
could you please review this patch.
Comment #7
AsadKamil commentedPatch applied successfully,
thanks.
Comment #8
magi.yv commentedComment #9
magi.yv commentedCreated a patch to fix the issue when using 'OR query' in search.
Comment #11
mslabba_zyxware commentedSuccessfully merged the patch
Comment #12
mslabba_zyxware commentedThis patch will fix this particular issue, but has effect on other areas.
After applying this patch 'disable search' functionality does not works as expected
Comment #13
magi.yv commentedFixed issue on 'OR' query and disable search feature. Please review the patch.
Comment #14
magi.yv commentedComment #16
mslabba_zyxware commentedSuccessfully merged the patch
Comment #17
anish.a commented