Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#19 | redirect_base_path_check-1198028-19.patch | 478 bytes | chellman |
#13 | redirect-drupal-subdirectory-fix-1198028-13.patch | 478 bytes | mxwright |
#12 | redirect-drupal-subdirectory-fix-1198028-12.patch | 456 bytes | mxwright |
redirect.module.patch | 483 bytes | gundarx | |
Comments
Comment #1
Connor Gilbert CreditAttribution: Connor Gilbert commentedMy 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.
Comment #2
cmseasy CreditAttribution: cmseasy commentedThanks for the patch, this solved my problem!
Please update the module with this patch
Comment #3
jaydub CreditAttribution: jaydub commentedComment #5
Dave ReidI'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?
Comment #6
Ishino CreditAttribution: Ishino commentedI 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.
Comment #7
Ishino CreditAttribution: Ishino commentedI might take a look at the following: https://drupal.org/node/708972 which seems to be related.
cheers
Dries
Comment #8
matthew@lucidchart.com CreditAttribution: matthew@lucidchart.com commented+1
Comment #9
derevo CreditAttribution: derevo commentedThe 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!
Comment #10
WiredEscape CreditAttribution: WiredEscape commentedBump... any update on this issue?
Thanks,
Comment #11
Summit CreditAttribution: Summit commentedHi,
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
Comment #12
mxwright CreditAttribution: mxwright commentedThe initial patch here worked for me, so I rerolled for 7.x-1.0-rc1
Comment #13
mxwright CreditAttribution: mxwright commentedSame patch, but for 7.x-1.x-dev
Comment #14
cmseasy CreditAttribution: cmseasy commentedpatch #12 worked for me
Comment #15
deanflory CreditAttribution: deanflory commentedWith 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:
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.
Comment #16
mxwright CreditAttribution: mxwright commented@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!
Comment #17
Pere OrgaClosed #1560076: Bluehost - not working for Primary Domain in a sub-dir as a duplicate of this one
Comment #18
aaronschachter CreditAttribution: aaronschachter commentedPatch in #13 works for me on my Bluehost hosted site. Running Redirect 7.x-1.0-rc1.
Comment #19
chellman CreditAttribution: chellman commentedPatch #13 works here too and doesn't seem to cause any ill effects. I've rerolled it against dev.
Comment #20
feddovdm CreditAttribution: feddovdm commentedGreat, patch #13 works!
Comment #21
Dave ReidComment #24
beckydev CreditAttribution: beckydev commentedWanted 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).
Comment #25
markusd1984 CreditAttribution: markusd1984 commentedI 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?