Drupal 7 Multisite - Infinite recursion [symlinks]

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

I've been pulling my hair out trying to figure out how to solve a problem I've been experiencing with a Drupal 7 multisite installation. I've searched frantically over the last while and I was hoping that perhaps someone has solved the issue I'm having. I found some very relevant discussions and information and there does not appear to be any solution contained in them.

See the following:

Description of the Problem
So, I have many sites all of which are subdirectories (not subdomains)

Site / Subsite location sites directory folder symlink
www.example.com default
www.example.com/department1 example.com.department1 department1
www.example.com/department2 example.com.department2 department2
www.example.com/department3 example.com.department3 department3
www.example.com/department4 example.com.department4 department4
www.example.com/<dept> example.com.<dept> <dept>

Now, they all work fine so long as one thing does not occur.

Suppose I the following 2 values for <dept>:

  • math
  • arts

The following paths would all render incorrectly:

www.example.com/math/arts
www.example.com/math/arts/arts
www.example.com/math/math/math/.../math/math
www.example.com/<dept>/<dept>
www.example.com/<dept>/<any other dept>

If I have a page named arts in the /math subsite, it becomes unreachable and loads the math homepage and vice-versa for /arts with a page named math.

This is very problematic in the case of common words such as 'research' or other potential department with common names.

For another example, if I have a research department, and math wanted to show off their research and have /math/research, it will not load the page.

Interestingly enough, if the path to the page contains a valid page before the second alias, there is no problem.
For example: www.example.com/math/not-a-department/arts, the page titled 'arts' will load correctly so long as not-a-department is also a valid page and clean path is appropriate.

Any ideas on how to fix this problem elegantly?

Thanks

Comments

This is probably something

Garrett Albright's picture

This is probably something configured very incorrectly at the web server level. Please give us more information. What sort of multi-site configuration are you using? What web server are you using, and what do its configuration files look like?

I can't help with a solution

OriginalSauce's picture

I can't help with a solution (not found one yet) but I don't think it's a problem with incorrect configuration at the web server level.

I have the same issue, although in my case it's an acceptable problem. As far as I can tell it's quite a common occurrence with using symlinks in this way.

A brief overview of my setup

CentOS running PHP 5.4.17 Apache/2.4.6

I have around 10 web sites running as single domain websites all working fine.

I have one website which is a multi-site setup exactly as indicated in the OP structure wise.

Each website has a vhost entry with an include file for additional adhoc config settings. These files are all set up correctly.

The sites share one codebase and all modules etc. Each site has it's own settings.php, theme folder, files for additional customisation.

For the multi-site each site folder has a named symlink in the root folder pointing to root.

The set up works very nicely apart from this issue.

Although I have some knowledge of rewrite rules etc, I am no expert and unable to find a satisfactory config to remove this recursion.

Exactly the issue

misterkay's picture

It sounds like you are having exactly the same problem.

I have 30+ sites running D7 with no issues aside from this problem.

The only difference between that and this is that I have Apache 2.2.x and running on REH5 and php 5.3.x. I don't have an vhost entries for the subsites, but clearly that doesn't make a difference if you're encountering the same recursive problem.

just to add as I realise it

OriginalSauce's picture

just to add as I realise it wasn't clear in my last post.

I don't have vhost entries for the subsites, only for the single domains and the main domain name used for multisite set up.

I'd also further like to add:

Although, as far as I'm aware this has no security implications, it has the potential for negatively effecting 'good' SEO, not to mention the problem misterkay has brought forward in his OP.

I think this should be addressed as a concern that needs better clarification and a fix/work around.

After all using symlinks is the advised/preferred method in the drupal.org multi-site setup instructions.

REH5 = RHE5

misterkay's picture

Just to clarify a mistake in my previous post. REH5 should read RHE5. I'm sure it was obvious, but mistyped in my haste.

Not sure if this helps, but I

DYdave's picture

Not sure if this helps, but I thought another discussion might be related:
Multi-site Symlink Works But Causing Infinite URL Subpath and Recursive Server Folder.

Hope this helps.

No answer

misterkay's picture

I referenced this in the original post as it IS related. No solution came out of that thread unfortunately. I was hoping with a little more time that perhaps someone might have solved this issue.

Hi all, We are also having

kyawzayl's picture

Hi all,

We are also having the same issue with this multisite symbolic links. We have several sites running with multisite configuration and we are facing the problem as below.

We have below sites running under multisite setup everything works fine.
http://site1.com
- at root there is a symbolic link created as 'site1'
- under sites foler there is, site1.com folder

http://site2.com
- at root there is a symbolic link created as 'site2'
- under sites foler there is, site2.com folder

http://site3.com
- at root there is a symbolic link created as 'site3'
- under sites foler there is, site3.com folder

However, with the above settings, we are able to do these recursive paths as below.

These we think is not good for the SEO and when we do the google search, these results are showing unexpectedly :(

Has anyone found out the solution yet? Thanks.

Possible solution

averyi's picture

I'm not sure if this will work for your situation(s) or not, but I was able to avoid this issue by not using symlinks on a four site install.

1. Set up Apache Alias(es) in the vhost for the subdirectory site(s) to the main instance:
Alias /directory /var/www
2. Use .htaccess rewrite rules to route to expected location:
RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/directory/(.*)$
  RewriteRule ^(.*)$ /directory/index.php?q=$1 [L,QSA]

In my setup it preforms as a symlink would, without the recursion. You may need to get rid of the query string depending on your config, of course.

See also https://drupal.org/comment/136227#comment-136227

Again, this may not be a solution for your situation but I thought it worth mentioning. Hope it helps.

Multisite

Group organizers

Group notifications

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

Hot content this week