I have a multilingual site, but I think the issue is just Domain Access.

$request_path gets the current path (e.g. node/2)

It then calls drupal_alter('url_outbound',$request_path, $options, $request_path);

Domain Access's version of hook_url_outbound_alter, domain_url_outbound_alter itself returns $request_path as the alias of the path, (e.g. "foo-bar").

So later on, when globalredirect redirects if $request_path != $prefix . $alias then it doesn't work as $request_path is already the alias.

(It does works for the multilanguage pages where there is a language prefix like "fr", but sites without a language prefix, e.g. using default language, fail.

I'm not sure how to get around this. Giving globalredirect a lighter weight than Domain Access works for the very first page load after a cache clear, but after that it stops working (presumably a caching thing of module hooks?).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

apemantus’s picture

Version: 7.x-1.4 » 7.x-1.x-dev
apemantus’s picture

OK; so I checked the code, and this works fine with 7.x-1.4, just not with the dev release, so I've gone back to that: so, umm, yeah. This is why I should check with non-dev versions first.

dgtlmoon’s picture

Not sure if this is the same, but check out this issue too #1215134: FYI, Domain Access Source and Global Redirect conflict

rudiedirkx’s picture

It's not the same.

I'm having this issue too. I don't understand why globalredirect calls url_outbound for the request path. The request path should be literal IMO. That's why DA 'conflicts', because it alters outbound urls, which makes sense obviously.

@apemantus What do you mean "works fine"? No conflict with globalredirect 1.4? I'm using 1.5 and it's not working. node/22 isn't redirected to my-alias even though it uses core paths.

apemantus’s picture

It sorta works fine with me now using Global Redirect 1.5.

The following works:

example.com/node/1 -> redirects fine to /page-alias
example.de/node/2 -> redirects fine to /german-page-alias
example.ch/node/2 -> redirects fine to /de/german-page-alias

The following doesn't work:

example.ch/node/1 -> redirects incorrectly, as it goes to /de/node/1 rather than /en/page-alias

(Although example.ch/en/node/1 redirects correctly)

I haven't looked into why example.ch/node/1 fails, but to be honest, I think that may be to do with reasons other than global redirect.

rudiedirkx’s picture

My site isn't multilingual, just multi-domain. With Domain Access and Domain Path on, all global redirects don't work... Very simple reason (after debugging) is the url_outbound alter in globalredirect_init() that's implemented by Domain Acess (using Domain Path). I still don't get why globalredirect calls the url_outbound alter on the incoming url...

apemantus’s picture

@rudiedirkx - ah OK, I think that is an issue to do with Domain Path specifically and Global Redirect - check out http://drupal.org/node/1706560 for a very quick suggested patch/hack to get it working, at least until someone suggests something better or there's a change in Global Redirect.

rimen’s picture

I think, we can pass additional parameter in $options array to inform other modules that hook_url_outbound_alter is invoked by globalredirect.
e.g.

// Establish the language prefix that should be used, ie. the one that
  // drupal_goto() would use
  $options = array(
    'fragment' => '',
    'query' => $query_string,
    'absolute' => FALSE,
    'alias' => FALSE,
    'prefix' => '',
    'external' => FALSE,
    'globalredirect' => TRUE, // inform other modules that hook_url_outbound_alter invoked by globalredirect
  );

Then we can check that it is the first or the second invoke of url_outbound_alter (we can add custom module parameter to options in the first call and check it on the second) and return alias only in the second invocation

rimen’s picture

in addition to #8
Support for Global Redirect in domain_path updated
http://drupal.org/node/1706560#comment-6968396

rimen’s picture

Status: Active » Needs review
FileSize
446 bytes

#8 Patch attached

maijs’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

I vote this to be merged in. In tandem with a patch in #1706560: Support for Global Redirect (#14) it solves the problem with redirection loop. This patch should not introduce any regressions and it allows a lot of flexibility for other modules.

BBC’s picture

Agree with maijs. Just tested this out (#10 patch here plus #14 from Support for Global Redirect) on a couple of sites and it is working quite well.

nizer’s picture

I concur, the patch in #10 seems to offer a workable solution.

pwiniacki’s picture

Good to know - I'm gonna test it, cause I'm building a site with use of DA. Gonna let you know if something is bad.

anydigital’s picture

Checkout this module as an alternative solution: https://www.drupal.org/project/domain_path_rewrite

Every internal path will be automagically redirected to the related domain path with it.

BarisW’s picture

Thanks. Looks good!

  • BarisW committed da905de on 7.x-1.x authored by rimen
    Issue #1411704 by rimen, apemantus, rudiedirkx, maijs, BBC, BarisW,...
BarisW’s picture

Status: Reviewed & tested by the community » Fixed

Committed to dev.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.