Download & Extend

alias weighting (redirect from multiple aliases)

Project:Global Redirect
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (won't fix)

Issue Summary

Hi there,

Something that I would like to see is a way to redirect from one alias to another (in conjunction with pathauto) or to set a preferred alias if more than one exist in the system.

Comments

#1

+1 on this - would solve some migration issues I'm currently trying to think out as well. If it's the quickest win, I might create a patch for this, but I'm not sure how it would work...? Maybe it's not really feasible? =/

#2

Here's a patch that solves this issue. It works by looking for another alias pointing to the same source, but with a lower pid (added first). This way you can have both /my-story and /legacy-url pointing to /node/123, but requesting /legacy-url yields a 301 redirect to /my-story.

AttachmentSizeStatusTest resultOperations
globalredirect-526888.patch1.22 KBIgnored: Check issue status.NoneNone

#3

This should be how the module works since it checks if the current path != drupal_get_path_alias(). If core doesn't return the proper alias with the API, it's a bug in core that needs to be fixed.

#4

Status:active» closed (won't fix)

I agree with Dave on this.

If core is not returning the correct URL for a path, that's a core issue. Otherwise I guess you should avoid having multiple url_aliases resolving to the same source. Try moving the secondary URL's to the Path Redirect module.

#5

Path Redirect looks like a good option. Don't know how I never used that before!

#6

There is also a drupal core issue. Have a look at #358315: drupal_lookup_path() not respects alias' order

#7

Not a really good code, but it's my solution and it seems to work (file : globalredirect.module) :

In hook_init function, replace this :

$alias = drupal_get_path_alias($request);

***end code ***

By :

$result = db_fetch_object(db_query("SELECT * FROM {url_alias} WHERE dst = '%s'", drupal_get_path_alias($request)));
$result2 = db_fetch_object(db_query("SELECT * FROM {url_alias} WHERE src = '%s' AND language='%s' ORDER BY pid DESC", $request, $result->language));
$alias = $result2->dst;

if ($alias) {
   ***end code ***
}

#8

Try Path Redirect - using it with pathauto and global redirect seems to work well for me.