Needs work
Project:
Global Redirect
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 Feb 2012 at 13:37 UTC
Updated:
14 Mar 2018 at 16:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
wojtha commentedThe following patch adds "Ignore paths" setting to the module settings and adds hook hook_globalredirect_active_path().
Example ignore path:
premium/*Example hook_globalredirect_active_path() implementation:
Comment #2
wojtha commentedHmm, might be it will be better to provide hook_globalredirect_active_path_alter() instead of hook_globalredirect_active_path(). What do you think?
Comment #4
wizonesolutionsI think the first hook makes more sense. Global Redirect's sole purpose is to redirect to a canonical alias; altering that behavior doesn't make sense.
hook_url_inbound/outbound_alterdo that job fine.Comment #5
webkomplize commented#1: 1438584-1_globalredirect_active_path.patch queued for re-testing.
Comment #6
rp7 commentedGoing to follow this one.
A temporary, but not so clean, fix for this might be:
This works because globalredirect only works on pages where $_POST is empty (see _globalredirect_is_active()). If there is other code (outside globalredirect) checking if $_POST is empty, you'll have to account for this though. You'll also need to make sure your mymodule_init runs before globalredirect_init.
A new hook would be awesome.
Comment #7
nicholasthompsonI very much like the look of this. Nice work!
Suggestions:
$function, could we use module_invoke?Apart from that, I'd say this is pretty close to RTBC..
Comment #8
make77 commentedIs there any news about implementing the "Ignore paths" setting for the next release ?
Comment #9
stefan.r commentedRe-roll against 7.x-1.x git
Comment #10
stefan.r commentedComment #11
stefan.r commentedIncluding feedback from #7.
1. Passing
$aliasas well.2. At the moment this depends on whether
case_sensitive_urlsis enabled so it's neither. Thinking we should pass lowercase paths anyway to prevent any issues. Only drawback of that is that we can't say,/some/pathshould not redirect while/Some/PATHshould but that seems like a very rare edge case anyway.3. using
module_invoke().Comment #12
stefan.r commentedThis one passes the lowercase version of both the path and the alias.
Comment #13
jun commentedAny chance this could be committed? Quite useful in my case to ignore a example.com/api path which holds a REST API that doesn't like 301s...
Comment #14
tyler.frankenstein commented#12 allows me to ignore all calls to my RESTful API (via the Services module and an endpoint path), e.g.
http://example.com/api/*Nicely done!
Comment #15
caspervoogt commentedWorks well. Please commit
Comment #16
anybodyGreat work, do you have a time plan when this will be commited? IT's RTBC since 3 month!
Comment #17
ekes commented+1 - also using to avoid /api (giving the hook also enables doing this in the config code with a simpler, than regex, strpos).
Comment #18
thomas.frobieterIt would be great if you could commit this sooooon as your time allows (:
Comment #19
Clemens Sahs commentedWorks great for me, too.
merge it
Comment #20
Seven_Six_Two commentedIs this going to make it in to a release any time soon?
Comment #21
nsciaccaI used the patch from #12 so I could write a custom "hook_globalredirect_active_path", but it was throwing a warning for $alias not existing. I moved some of the lines that defined the alias to outside the if statement process ignore paths so it doesn't throw the warning. Should still work.
Comment #22
markpavlitski commentedMarking as needs review for patch in #21.
Comment #23
stefan.r commentedseems OK to me
Comment #24
tyler.frankenstein commented@stefan.r, what's your latest attachment for?Comment #25
markpavlitski commented@stefan.r Thanks for the interdiff, looks good to me too and does fix the $alias warning. Marking back as RTBC.
Comment #26
mausolos commentedHi, it's been 8 months as RTBC, is there a schedule for pushing this out sometime? :)
Comment #27
alexkb commentedI've just tried this patch for a different use case: disabling globalredirect for a particular page in Drupal that has an embedded angular application with html5mode toggled on. It seemed to work great, thanks!
Comment #28
oleksiyThanks for the patch. It's very useful in my case.
I use hook_globalredirect_active_path($path, $alias) to exclude some pages from global redirect. However, when I requested a page using page alias in $path and $alias variables I got the same value for both variables (requested alias). So I can't limit pages by system path. Also my site is multilingual and I get the path\alias with attached language prefix in the hook.
In the previous patch the request_path() function is used to get the path which will be used for ignore list. I propose to use current_path() function instead. Then we can get system path of the requested page and retrieve an alias if it exists and they will be without language prefix
Comment #29
webadpro commentedId have to agree with Oleksiy, that using current_path() could probably be more useful than request_path().
Patch still works great.
Comment #30
vincenzodb commentedPatch to 7.x-1.5 version
Comment #31
dripa commented#30 worked, thanks!
Comment #32
jimmynash commented#30 worked for me as well.
Comment #33
tyler.frankenstein commentedComment #34
ankitnigam30 commented#30 worked great for me as well.But this is not added in 7.x-1.5 version.
when this will be commited in next release ?
Comment #35
jlongbottom commented#30 is working for me
I actually need to ignore all pages for a certain entity type, so I had to get creative with the wildcards. If there was not any static text in my entity's URL pattern, I would not have been able to use this patch for my use case.
So its just an idea, but it would be great for this to work per entity or bundle instead of using paths.
Comment #36
ruchirashree commentedThis is working as expected. This is currently not in the stable release version 7.x-1.5. It will be great to have this in current stable release. @blueminds, request you to please take it forward.
Comment #37
jamesdevware commentedA slight modification to _globalredirect_is_active_path() which ensures that $path is always the internal path if one exists. Without this globalredirect_active_path can end up in a situation where $path is actually an alias.
Patch and interdiff attached (rolled against 7.x-1.5, patch does not currently apply cleanly against dev).
@jlongbottom this patch should help you to match by internal path either using pattern or hook_globalredirect_active_path as the internal path will now be checked.
Comment #38
jamesdevware commentedI realised that my previous patch would mean that you couldn't match based on the request_path.
New patch allows for matching by internal path as well as the alias / request path.
interdiff is attached against #30 again please ignore #37.
Comment #39
jamesdevware commentedPrevious patches were not working when using multilingual based on path prefix.
New patch includes path sanitisation to remove the language prefix ensuring that patterns will match across all languages.
Comment #40
tennist commentedPatch from 39 works for me. Can we get this committed in the next stable release.
Comment #41
fgjohnson@lojoh.ca commentedInteresting,
We use Deployment between an Authoring server and Production server.
Deploy fails with Global Redirect turned on.
Where do I enter the paths to ignore?
Or Maybe I don't.
This looks great!
Thanks
Comment #42
thomwilhelm commentedLooks like this missed the latest release 7.x-1.6
Comment #43
fgjohnson@lojoh.ca commentedYes it did.
And the patch #39 doesn't apply.
Comment #44
fgjohnson@lojoh.ca commentedWe are running behind a varnish server.
Adding these "paths to ignore" doesn't work.
I assume it's because the base_url in settings.php is the live varnish URL...
Any idea's?
Adding user/* and admin/*
production.site.com is the drupal site...
varnish.site.com is the varnish/public URL.
Once enabled ALL attempts to get to /user just redirect to varnish.site.com .
Thanks
Comment #45
fgjohnson@lojoh.ca commentedLast hunk of patch in #39 doesn't apply to 7.x-1.6.
Comment #46
fgjohnson@lojoh.ca commentedThis patch is for 7.x-1.6.
Why did it fail testing? Because testing is against -dev?
patching file globalredirect.admin.inc
Hunk #1 succeeded at 112 with fuzz 2 (offset 8 lines).
Hunk #2 succeeded at 159 (offset 8 lines).
patching file globalredirect.module
Hunk #1 succeeded at 326 (offset 35 lines).
Hunk #2 succeeded at 401 (offset 35 lines).
Hunk #3 succeeded at 498 (offset 35 lines).