Hi,

Not sure if this is really a bug, but in my development (and test) environments, we use wildcard subdomains through mod_rewrite to deploy our Drupal multi-sites. This has an impact on the $_SERVER['SCRIPT_NAME'] (some internal path with directories) and base_path which Drupal only thinks as being "/". I was wondering why the Redirect module was not working at all in my tests and it boiled down to this line. I've attached a patch for the current dev. version. Hope this helps someone out there. This is a great module, BTW!

Jake

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Connor Gilbert’s picture

My Drupal site lives in a subdirectory with some rewrites that affect the URL path, and my URL redirects were returning Drupal 404s. This patch solved the issue for me.

cmseasy’s picture

Thanks for the patch, this solved my problem!

Please update the module with this patch

jaydub’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, redirect.module.patch, failed testing.

Dave Reid’s picture

Status: Needs work » Postponed (maintainer needs more info)

I'm not quite I understand if this is something Redirect should fix or if it's an environment problem.

What are the two values of $_SERVER['SCRIPT_NAME'] and $GLOBALS['base_path'] when this happens?

Ishino’s picture

I have a similar problem on a project. It's a hosting used for governement sites and they have a setup which isn't manageable for third parties.

When I check the values on DOMAIN.COM/blog which should be redicted, I get the following:

$_SERVER['SCRIPT_NAME'] = '/blog'
$GLOBALS['base_path'] = '/index.php'

So I not sure it's safe to check this before allowing redirects.

Ishino’s picture

I might take a look at the following: https://drupal.org/node/708972 which seems to be related.

cheers

Dries

matthew@lucidchart.com’s picture

+1

derevo’s picture

The patch in the OP no longer lines up with the line numbers in 7.x-1.0-rc1, but the patch itself seems to fix the problem. Redirects now work for me while serving Drupal from a subdirectory, with and without a subdomain.

The new line number that the patch should be applied to is line #1153 as of 7.x-1.0-rc1.

Thanks for your help gundarx!

WiredEscape’s picture

Bump... any update on this issue?
Thanks,

Summit’s picture

Hi,

Will with patch http://drupal.org/files/issues/redirect.module.patch Redirect work as subdirectory, but also still as directory?
I still didn't get redirect to work adding this patch....

I have upgraded website from D6 to D7 and I had taxonomy/term redirect in this website
Now the taxonomy/term redirect do not work anymore..
EDIT NO redirect is working anymore..

greetings, Martijn

mxwright’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
456 bytes

The initial patch here worked for me, so I rerolled for 7.x-1.0-rc1

mxwright’s picture

Same patch, but for 7.x-1.x-dev

cmseasy’s picture

patch #12 worked for me

deanflory’s picture

Issue summary: View changes

With the current 7.x-1.x-dev 2013-Oct-01 release, the patch in #13 applied with these results on Drupal 7.27 with the root in a subfolder:

patching file redirect.module
Hunk #1 succeeded at 1153 (offset 3 lines).

Upon updating the site with the patched version of redirect, I am still not getting any functionality out of the redirect module.

None of the redirects work, automatically created nor manually created, so this patch did not fix my issue and there is clearly a major problem with the module on my install on my server.

mxwright’s picture

@deanflory This patch also stopped working for me some time ago, so I retried it recently and after a lot of cache clearing, it seems to work again.

Besides the cache-clearing, one issue seemed to be the amount of circular redirects I had in place (where url alias and redirect match), due to previous importing of nodes during development.

I got rid of those and applied the patch from this issue to prevent it from happening again: #1796596: Fix and prevent circular redirects

Hopefully works for good now!

Pere Orga’s picture

aaronschachter’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #13 works for me on my Bluehost hosted site. Running Redirect 7.x-1.0-rc1.

chellman’s picture

Patch #13 works here too and doesn't seem to cause any ill effects. I've rerolled it against dev.

feddovdm’s picture

Great, patch #13 works!

Dave Reid’s picture

Status: Reviewed & tested by the community » Fixed

  • Dave Reid committed 8da3096 on 7.x-1.x authored by chellman
    Issue #1198028 by mxwright, gundarx, chellman: Redirects do not work if...

Status: Fixed » Closed (fixed)

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

beckydev’s picture

Wanted to give my thanks to #7 which pointed me to the right fix for my issue using 7.x-1.0-rc3 (which has the patch in this post applied).

markusd1984’s picture

I have this in the current version, but in my case, the check prevents the redirecting from working, even though my rewrite points to /index.php.

https://www.drupal.org/project/redirect/issues/2995563#comment-12760644

When I disable it my redirects get access and are working. Any ideas?