After enabling a second language (Greek) on my new Drupal 7.9 installation, when saving the new language as the default the site went into a redirect loop (Firefox: "The page isn't redirecting properly" message).

Enabled modules:

  • Locale
  • Global Redirect [7.x-1.x-dev (2011-May-03)]
  • i18n (7.x-1.1)

I am totally unable to access the site now.

Tried disabling Global Redirect and i18n in the DB and by renaming their module directories but to no avail.

Opening against core for initial evaluation, as Global Redirect has already fixed such an issue and I have the same GR version installed on a production site without issue.

Please advise on how I can at least access the site again. Thank you.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

good_man’s picture

Project: Drupal core » Global Redirect
Version: 7.9 » 7.x-1.x-dev
Component: language system » Code

It's a Global Redirect bug, moving to there.

good_man’s picture

Status: Active » Needs work

For now to solve your problem quickly. Open globalredirect.module, go to line #218:

  if ($request_path != $prefix . $alias) {
    // If it's not just a slash or user has deslash on, redirect
    if (str_replace($prefix . $alias, '', $request_path) != '/' || $settings['deslash']) {
      drupal_goto($alias, $options, 301);
    }
  }

and comment this line:

  if ($request_path != $prefix . $alias) {
    // If it's not just a slash or user has deslash on, redirect
    if (str_replace($prefix . $alias, '', $request_path) != '/' || $settings['deslash']) {
      //drupal_goto($alias, $options, 301);
    }
  }
good_man’s picture

Status: Needs work » Needs review
FileSize
955 bytes

This patch should make the necessary checking before entering a new redirection loop.

marktheshark’s picture

Any chance of this fix getting committed?

Thanks

PESTO3567’s picture

My Website was also broken because of this Bug. Hope the fix will be committed soon.

marktheshark’s picture

Any closer to being reviewed?

saidij1976’s picture

thank you good_man, that solved my problem.

carusen’s picture

This patch should be included in a new release. I had the same issue and, to figure things out I wasted 6 hours and 4 drupal reinstalls. :(

wiherek’s picture

Using the dev version solved that problem.

alby111’s picture

after enabling global redirect in my new Drupal 7.10 installation, when saving this version module 7.x-1.4

the site went into a redirect loop , I was unable to access the site so I used solution number 2 Posted by good_man

and then I was able to disable Global Redirect , suggestions wellcome

wiherek’s picture

alby111: did you apply the patch?

For other users experiencing that problem:
if you cannot access the site via UI, you can still disable the module using drush.

mallezie’s picture

The patch in #3 does not apply to version 7.x.1.4

error: patch failed: globalredirect.module:216
error: globalredirect.module: patch does not apply
-sh-3.2$ git apply -v 1337132-3.patch 
Checking patch globalredirect.module...
error: while searching for:
  // Compare the request to the alias. This also works as a 'deslashing'
  // agent. If we have a language prefix then prefix the alias
  if ($request_path != $prefix . $alias) {
    // If it's not just a slash or user has deslash on, redirect
    if (str_replace($prefix . $alias, '', $request_path) != '/' || $settings['deslash']) {
      drupal_goto($alias, $options, 301);
    }
  }

error: patch failed: globalredirect.module:216
error: globalredirect.module: patch does not apply

SocialNicheGuru’s picture

the patch above worked.

Kristen Pol’s picture

@SocialNicheGuru - you said the patch worked. What version of the module did you patch?

Thanks,
Kristen

SocialNicheGuru’s picture

the latest dev version

mallezie’s picture

I tried to apply to the 1.4 version, so that's probably the cause. Thx for the help.

sw3b’s picture

I can confirm #3 work on latest DEV it solve the problem ! I patch on 6 differents installation and it work.

Kristen Pol’s picture

Status: Needs review » Reviewed & tested by the community

Several folks have confirmed the patch on dev version.

Kristen

sgabe’s picture

I can confirm that the patch in #3 works. Please, review and possibly commit ASAP.

FiNeX’s picture

Patch #3 works fine, I strongly suggest to commit.

Gábor Hojtsy’s picture

@good_man: is $break used later in the code? Why not build it into the second condition or give it a more meaningful name? :)

joecanti’s picture

Patch work great - thanks!

#3 on the latest dev (Dec 30 2011)

Joe

Letharion’s picture

Status: Reviewed & tested by the community » Needs work

$break is not used later in the code as far as I can tell, so patch needs work. Based upon the number of commenters who claim that it works anyway, probably just means the $break refs can be removed.

Letharion’s picture

My bad, it cannot ofc not be removed, but it should be named something more meaningful, as suggeted in #21.

ozcan’s picture

This thread is still a life-saver! Thank you once more good_man...

wizonesolutions’s picture

Is this fix still not committed? I think the language redirect is already committed, unless that fixed a different issue.

marktheshark’s picture

Still encountering this problem.
Workaround: disable module, enable languages, then re-enable module.
If you have it enabled while the enabling an additional language you're going to get a loop.

Kristen Pol’s picture

:( I'm sooo bummed this still isn't working... maybe @wizonesolutions can help (nudge, nudge :)

ckng’s picture

Status: Needs work » Needs review
FileSize
965 bytes

Per #21 comment
- change $break to $redirect
- check $redirect first, the rest is not needed if it evaluates to false

marcoka’s picture

#1378690: Update to 7.x-1.4 adds duplicate language prefixes, causing a redirection loop seems to be fixed, anyone tested 1.5 against that issue yet?

meno1max’s picture

Just tested it on a site in Italian and it looks like it's working as expected.

Anybody’s picture

This is a really really big problem and still not solves in the latest .dev version (at least for my test environment).

This bug is quite old and critical - how can we get it fixed ASAP?

Anybody’s picture

Here you can find my description of the problem and a temporary solution that fixes the redirect loop by disabling the Language path check-option (in German):
http://julian.pustkuchen.com/drupal-7-i18n-global-redirect-pruefen-der-s...

Of course this still has to be fixed by pre-checking the existence of a translation before creating the redirect in the Global Redirect module.

Anybody’s picture

Issue summary: View changes

Added module version specifics

RavindraSingh’s picture

Issue summary: View changes

I am not able to replicate it on version = "7.x-1.5". Enabled locale, global redirect and content translation. I have tried by doing:

1. Setting default language HINDI in locale
2. Adding redirect to all languages from one content
3. Tested existing redirect URLs

but still unable to replicate so these patches .So not required to be committed in 1.5 release.

my-family’s picture

I had the same problem with the 1.5 version, when the "Language Path Checking " option was checked. After disabling this option, everything works.

aufumy’s picture

The 1.5 version did not work for me with "Language Path Checking" on or off.

Using multilink module, was able to have the redirection happening.

Besides redirecting the node ids to the clean url, it would also take into consideration what language you chose for the website currently, if you typed in the node id of an alternate language page, it would redirect you to the equivalent page in your current language.

Chris Matthews’s picture

Status: Needs review » Closed (outdated)

The 7 year old patch in #29 to globalredirect.module does not apply to the latest 7.x-1.x-dev, but looks like it should be closed as outdated as the fix is in #1378690: Update to 7.x-1.4 adds duplicate language prefixes, causing a redirection loop.

Checking patch globalredirect.module...
error: while searching for:
  // Compare the request to the alias. This also works as a 'deslashing'
  // agent. If we have a language prefix then prefix the alias
  if ($request_path != $prefix . $alias) {
    // If it's not just a slash or user has deslash on, redirect
    if (str_replace($prefix . $alias, '', $request_path) != '/' || $settings['deslash']) {
      globalredirect_goto($alias, $options);
    }
  }

error: patch failed: globalredirect.module:215
error: globalredirect.module: patch does not apply