"Forced" path redirect - override the existing path or alias
PlayfulWolf - October 26, 2009 - 17:27
| Project: | Path Redirect |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
| Issue tags: | 6.x-1.0 blocker |
Jump to:
Description
Hi,
It could be a great addition to have ability to "force" url redirects, even if current path exists on the system.
I have started that discussion on consulting@drupal list
The only urls which should be protected from those redirects - admin/*

#1
Seems like many use cases would be to redirect valid urls from one place to another (only reason i need it). It seems like we're being over cautions to put any limitation on this, I mean the admin could always undo it from the DB if they did something really messed up like redirecting /user (though perhaps you might want to do that exact thing).
In fact the help text suggests that you can do this.
The project page says "This module allows you to specify a redirect from one path to another path or an external URL" - no mention of a limitation.
The path field help text says: "Enter an interal Drupal path or path alias to redirect (e.g. node/123 or taxonomy/term/123). Fragment anchors (e.g. #anchor) are not allowed." - again, no mention of a limitation.
The list page says "Here you can set up URL redirecting for this site. Any existing or non-existing path within this site can redirect to any internal or external URL." - definitely suggesting that you can use "existing" paths.
Is this limitation new?
#2
We do need to provide some kind of protection for overwriting existing paths, which this issue will accomplish with a two-step form process, but still allow you to do it.
The limitation is not new, but it's best practice that existing paths should not have redirections, they should have aliases (and you can use global redirect in order to peform redirections from alias to path).
#3
Hi Dave, could you describe this best practice in a little more detail or point us to another post? Im trying to get things like "taxonomy/term/id" to redirect to an access denied page or a homepage and I need to do it on several node pages as well (full post at http://drupal.org/node/618824). I imagine many other pseudo-newbies like me would be really grateful if you could give us further clues... Many of us look into Path redirect and start getting the "You cannot create a redirect from a currently valid path" error.
How does Global redirect perform redirections from alias to path?
Thanks!
#4
I suggest an access role, so only admin and privileged users can use forced redirect feature.
#5
If root user caught XSS, it doesn't matter, as he will able to change anything in any case, so what for we should make some special logic? Plus, on 99% of sites only admins are the people who manage redirects, so why should we provide more access? To get them even more rights, which they already have? As for me, max. we should do it's provide very noticing warning if user wants to make dangerous redirect (/admin/* → ..., /user/1/* → ...).
#6
I guess admin can grant access to path redirect for specific users, in that case a different rule might be useful.
But anyway i'm agree that a warning is a useful reminder
#7
Hi everyone, I wrote comment #3 because Im looking for a way to do some of these "valid path" redirects (since it doesnt seem possible to tell Drupal not to create those paths from the start to avoid all this hassle).
How can I tell "taxonomy/term/id" to redirect somewhere else? I dont want those pages to be seen (or indexed).
#8
+1 for this. Here's our scenario:
the 'taxonomy/term/%' path is good for most needs, but for a handful of terms (all in the same vocabulary) would like to use a view to override how they look.
It is possible to use a view to override all term output (this is what the disabled-by-default taxonomy term view does) but this isn't what we need as it's an all or nothing case and we only need a single vocabulary (or handful of terms) overriding.
I can set up a view on some other path, eg: 'some_other_path/%' and use taxonomy names as an argument (eg: 'some_other_path/term-name'. This is great with the exception of the taxonomy links under nodes always link to 'taxonomy/term/tid'.
Hence, I'd like to setup a handful of redirects from 'taxonomy/term/tid' -> 'some_other_path/term_name'.
In the absence of a better solution I made a small module and used
hook_term_pathto place alternate URLs to those the default taxonomy module would use.#9
Re: #8... scrub that, there are two further options that aren't really anything to do with paths but achieve the same result so will post as someone might find them handy:
1. Override each specific taxonomy term with a view. Not nice as you have to create a page override for every term.
2. Create a custom module for and menu entry for 'taxonomy/term/%my_tid_check'. Create a
my_tid_check_loadfunction and have it return FALSE for any tid that you aren't interested in. Then the page callback you specify will only be called for terms you want. Have that callback return the output ofviews_embed_viewusing the argument given and you're done.Option 2 is definitely the better of these two and is what I have used.
#10
Adding tag.
#11
Merging the idea from #511322: Redirect setting to overrule path-alias into this issue. The idea is to allow the redirect creator to decide if instead of overriding an url alias, to delete the alias when creating the redirect instead of just overriding it. Not sure what I think of it yet however.