Multi-site symlinks conflicting with sub-site path aliases

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
emptyvoid's picture

Hello,
So here is my problem, I created a multi-site installation of Drupal using a single source tree with 50+ sub-sites using symlinks for each. The problem I have is if I try to create a page alias on a sub-site that is the same as another symlink sub-site directory Drupal will not display the page. Instead Drupal will validate the URL as the first sub-site's home page.
Here is an example

1) I have a default site at:
www.example.com

2) I have two sub-sites
www.example.com/math
www.example.com/arts

If on the math sub-site I attempt to create a page using pathauto like so:

www.example.com/math/arts

Apache and Drupal will get confused, instead of evaluating "/math/arts" are "/math/" as a symlink and "/arts" is a path alias Apache and Drupal just get confused and ignore anything after "/math/" if the path is also a symlink directory.

I should state that my symlinks all link back to the root of the Drupal installation to make the sub-sites load correctly.

Any ideas on how to fix this?

I have been researching creating a series fo mod-rewrite conditions and rules.. but still haven't got anywhere.. I really hope I don't have to hack the core to address this issue. If anyone has experienced this before I would happy to hear how you solved the problem.

Comments

Are you setting the

robertgarrigos's picture

Are you setting the $base_url variable in each settings.php file?


Robert Garrigós
Professional site: garrigos.cat


Robert Garrigós
Professional site: garrigos.cat

Yep URLs set per sub-site settings.php

emptyvoid's picture

Hello Robert G,
Yep each sub-site has a settings file that is configured to include the base_url; each base_url contains the symlink directory.

Here is what I am working on right now but it is still giving me trouble.

.htaccess
#RewriteCond %{REQUEST_URI} ^/([^/]+)/.+$ $1 -l
#RewriteBase /$1
#RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

I am also considering on something along the lines of this.. but I don't want to "have" to do this.
http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide.html

The example is the last item under the External Rewriting Engine section. This would be pretty costly and may not scale well once I start to get into the realm of 100s of sub-sites..

Robert Foley Jr
Application Architect
http://www.robertfoleyjr.com || http://www.swipht.com"

Robert Foley Jr
Solutions Architect
http://www.robertfoleyjr.com

I should state that my

Garrett Albright's picture

I should state that my symlinks all link back to the root of the Drupal installation to make the sub-sites load correctly.

Woah, you're bogglin' my mind… Then how does site have its own settings.php? There's a disconnect somewhere here…

Simple really, well ok not really. :)

emptyvoid's picture

Well, Drupal provides several different ways to create sub-sites the technique that I am using is a single source tree of Drupal drives all of the sub-sites.

-

-

< drupal root >
----< sites >
-------< default > <- Drupal root site
-------< www.example.com.math > <-math sub-site
-------< www.example.com.arts > <- arts sub-site

Each directory is sites is setup as:

< default > <- this is different for each site
--settings.php
---< files >

For each sub-site I have a symlink in the root pointing to the root of the Drupal installation for example:

< Drupal Root >
--- + /math/
--- + /arts/

My issue may only be related to the sub-site technique I am using (a single source tree), I am curious if anyone else has experienced this problem with setting up multiple sub-sites.. The idea of duplicating the Drupal source code for each sub-directory is not a real sub-site installation, at least not from what the handbooks have stated.

Thoughts?

Robert Foley Jr
Application Architect
http://www.robertfoleyjr.com || http://www.swipht.com

Robert Foley Jr
Solutions Architect
http://www.robertfoleyjr.com

Okay, that's an interesting

Garrett Albright's picture

Okay, that's an interesting set-up, but it sounds like everything's behaving correctly. If you're on the math site and you want to link to an arts page on the math site, you create it with just the path "arts". Its full path will then be example.com/math/arts. If you try to create it with the path "math/arts", its full path will end up as example.com/math/math/arts.

Usually when people use Drupal's standard multisite system, they're not trying to use the same full domain name with all sites. There's at least a different subdomain prefix; so instead of example.com/math and example.com/arts, there'd be math.example.com and arts.example.com. That way, symlinks aren't necessary. Maybe it's too late, but I would suggest considering a structure like that instead; it might save you and the site's other content editors some confusion in the long run.

Nope, as designed

Boris Mann's picture

Actually, this is EXACTLY how multisite was designed. The symlinks are needed as described above (and are in the setup instructions) if you want to do example.com, example.com/subsite etc. etc.

And yes, the alias issue is known. If you do math/arts on example.com, underneath it's actually example.com/node/23. Basically, you're hitting some edge cases with the fact that each site doesn't know about the other.

Considering I am experiencing

coderintherye's picture

Considering I am experiencing the exact same problem, and ended up on this page, it'd be really great that if the issue is indeed known, we could link to said issue.

In my case, there are dozens of sites, but two conflicting are

drupalsite.com/campus/bus
drupalsite.com/campus/news

with sites/[foldername] being:

drupalsite.com.campus.bus
drupalsite.com.campus.news

And so on the bus subsite a link to drupalsite/campus/bus/news makes Drupal confused, so it ends up point back to drupalsite/campus/bus and drupalsite/campus/bus/news/headlines will return a 404 not found.

Drupal evangelist.
www.CoderintheRye.com

Does setting the $base_url in

redndahead's picture

Does setting the $base_url in settings.php help anything? Also in .htaccess you may want to try setting the rewrite base to /campus Just some ideas to throw out there.

Unfortunately, this just

coderintherye's picture

Unfortunately, this just leads to a recursive loop.
I guess I'm giving up, spent 8 hours trying all kinds of Apache rewrite tricks and delving into bootstrap.inc and can't find a solution that doesn't involve hacking core. :[

Drupal evangelist.
www.CoderintheRye.com

Symlinks suck. :-)

Mile23's picture

"For each sub-site I have a symlink in the root pointing to the root of the Drupal installation for example:"

Why? Drupal figures this out for you without needing any symlinks. That's why you have the www.example.com.math (and .arts) subfolder in the first place. If you sprinkle symlinks in the root Drupal directory, then results would be ambiguous at best. You want to let Drupal make all these decisions and keep Apache out of it.

i have also problem in one

Drupal-Tech's picture

i have also problem in one site like i have multisite like

mysite.com/site1

here i am able to open my site from url like .. http://mysite.com/site1/site1/site1 ...
this will always open site mysite.com/site1 ... how can i restrict to access site via url like http://mysite.com/site1/site1/site1

can any one suggest .htaccess rule to restrict this?

Thanks in advance...

I have same problem

meytad's picture

I have same problem

Same Infinite Recursion Here -- with Symlinks

rCharles's picture

Same issue. Recursion. Security Issues???

Seems a comprehensive tutorial should be in the multi-site documentation if Drupal is "advertised" as a subfolder option.

Yes ,I have same problem in my website

shabanbi's picture

I have created symlinks for multisite subfolders
like ex :- "http://website.com/subfolder1"
"http://website.com/subfolder2"
"http://website.com/subfolder3"
i have created symlinks on command line like
"ln -s . subfolder1",
"ln -s . subfolder2"
"ln -s . subfolder3",
then i created folder

"website.com.subfolder1"
"website.com.subfolder2"
"website.com.subfolder3"

in public_html/sites/ path . My multisites working fine but it taken infinite url paths for every subfolder ex:-

i)http://website.com/subfolder1/subfolder1/subfolder1/subfolder2
ii)http://website.com/subfolder2/subfolder2/subfolder1/subfolder3
iii)http://website.com/subfolder3/subfolder3/subfolder2/subfolder3

Please advise me how to avoid this infinite url path recursion in drupal 7 ?

Regards,
shabanbi

We found a solution

ploviem86's picture

A bit late maybe but for further reference ... my colleague asked the same question on stackexchange without any luck. But finally we found a solution for this issue. You can find it right here as an answer to the question we asked: http://drupal.stackexchange.com/questions/144434/multisite-path-issue

Still works like a charm :)

This solution is not ideal in

misterkay's picture

This solution is not ideal in the case of a large number of subsites. Consider the case of 80 different subsites. Every request that comes in now has to run through those 80+ checks. For 2 or 3 it's fine, but it's not really an elegant solution.

I guess you're right. We only

ploviem86's picture

I guess you're right.
We only have 7 subsites at the moment, not a problem (yet) I suppose.

We have not found (or looked for) another solution. If anyone has suggestions ...

Subfolders names in sites

jurco's picture

I would like to ask you different thing. What is the subfolder name you have your subsites in sites folder?

For example my site is http://zahorskabystrica.fara.sk/ and I created a symlink "piusx" pointing to the root. What should be the subfolder name in sites to have another site at http://zahorskabystrica.fara.sk/piusx?

I tried to create zahorskabystrica.fara.sk.piusx but this doesnt work. Nor pure piusx doesnt work.

Thanks in advance.

martin

You don't need (or want) the

Garrett Albright's picture

You don't need (or want) the "piusx" symlink.

If I recall correctly, you subsites need to use a different hostname than the main site. So you'll want to create a new subdomain of piusx.zahorskabystrica.fara.sk (or something like that) and point it to the same web root as zahorskabystrica.fara.sk. Then create a piusx.zahorskabystrica.fara.sk directory in your "sites" directory.

Multisite

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week