I was setting up a multiple site using the multiple settings.php feature (I like it very much!), but I was not able to get it working. I wanted to have at www.mysite.org/site2 a different drupal site. I created www.mysite.org.site2 folder in the sites folder and I put in a new settings.php. But it didn't work, i got "Page not found"...
By inspecting settings.php search algorithm in bootstrap.inc, I eventually found out that bootstrap conf_init() catches page paths with PHP_SELF. So it everytime gets www.mysite.org/index.php even if the path looks like www.mysite.org/site2/node/add. The reason is explained here. So I changed the line 52:

$uri = explode('/', $_SERVER['PHP_SELF']);

to

$uri = explode('/', $_SERVER['REQUEST_URI']);

and now it works.

I was reluctant to post this issue because it is a problem that should be come out long before. As it seems to me that without this fix there's no way to get it work, I'd like to know if i'm right and somebody else had the same problem, or it's only me (nobody has posted issues about that)! Have I forgotten setting some apache config, or what else?

Salvatore

Comments

jhriggs’s picture

We cannot use REQUEST_URI, because it is only available with Apache, not with IIS. Your change should work fine for you with Apache, or you can accomplish the same thing using symbolic links. See http://drupal.org/node/275.

Salvatore Montefusco’s picture

On my web server I cannot create sym-links, so the change above is necessary.

It actually seems that the function request_uri() in bootstrap.inc already provides a way to emulate REQUEST_URI on IIS. Maybe changing $uri = explode('/', $_SERVER['PHP_SELF']); with $uri = explode('/', request_uri()); could be fine for both Apache and IIS.

Anyway, after the change above, it's necessary to add the following lines to .htaccess, before the other rules:

RewriteRule ^site2$ /site2/ [L,R]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^site2/(.*)$ $1 [L]

and with this config it's also possible to activate clean urls. Unlike sym-links method, the mod_rewrite method requires that you don't create the directory site2.

Theo Schouten’s picture

It worked for me on a Linix host with Apache as described in http://drupal.org/node/275 .
If you don't have telnet access to create symbolic links, you can use FTP and a PHP file to create them, see http://drupal.org/node/275#comment-10937

nbd’s picture

Important - for the changes above to work - remove the remark from the line
LoadModule rewrite_module modules/mod_rewrite.so
in Apache's httpd.conf file.

-Nir-

hotgazpacho’s picture

Status: Closed (works as designed) » Reviewed & tested by the community
StatusFileSize
new400 bytes

Execellent solution, Salvatore!

One wonders why the development team noticed the problem, created a function to solve it, but did not use it in such an important place!

I have created a patch for 4.6.3 (a simple change, yes, but I have found I prefer patch files to directions).

marafa’s picture

i believe its a php issue and not an IIS issue:
http://drupal.org/node/20663#comment-52230
used this parent's solution to get multisite to work on IIS/Windows/PHP.

killes@www.drop.org’s picture

Is this also an issue with cvs/4.7?

moshe weitzman’s picture

@killes - yes it is.

killes@www.drop.org’s picture

Version: 4.6.0 » x.y.z

Then let's move it there so it gets some attention.

spyderpie’s picture

Hi, I'm a newbie - I ran into the same issues listed here. I have 4.6 and am running Apache and whatever the standards at opensourcehost are.

I took all of the recommendation listed here and was not sucessful in my configuration - but I did find a workaround.

I have the following setup and working now.

http://site1.domain.com as a subdomain pointing to public_html/site1 and
http://site2.domain.com as a subdomain pointing to public_html/site2 (not actually configured yet, just a subdomain available.)

I am also using MultiSite configurations. So a user may access their multisite by going to

http://site1.domain.com/mymultisite and it resolves to
http://domain.com/site1/mymultisite

site1 is a production system, single database, multisite (prefixed, shared and unshared tables)
site2 is a test system, separate single database, multisite (prefixed, shared and unshared tables for testing)
I have not turned on clean URL's yet, and don't know if I will have a problem.

My settings.php in the mymultisite folder contains:
$base_url = 'http://domain.com/site1/mymultisite';

And the change for the bootstrap.inc file recommended below.
$uri = explode('/', request_uri());

AND I had to add the following to my .htaccess file:

#put in the .htaccess file by cPanel when I created the subdomain site1
RewriteCond %{HTTP_HOST} ^site1.domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.site1.domain.com$
RewriteRule ^(.*)$ http://domain.com/site1 [R=301,L]

#added to make the multisite 'mymultisite' work
ReWriteRule ^site1.domain.com/mymultisite /site1/mymultisite/ [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^mymultisite/(.*)$ $1 [L]

Quite honestly, I'm not really sure what these settings mean per say, although I do understand the theory. I actually just moved over from the Windows world (my IT career for the past 12 years) and have never worked with Linux / Apache before, so this is all relatively new to me.

I thought this might be helpful for this new patch and for others using multisites, with drupal installed in a subdirectory. If anyone sees any issues I may run into, please - I would welcome the advice!

Warm Regards, Julie

killes@www.drop.org’s picture

Status: Reviewed & tested by the community » Needs work

the patch is for 4.6, we need a patch for cvs head.

Jaza’s picture

Version: x.y.z » 6.x-dev

Not sure if the patch in this issue is still needed, as conf_init() in Drupal 5 now has this:

$uri = explode('/', $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_FILENAME']);

Please close if this is no longer an issue.

mdupont’s picture

Status: Needs work » Closed (fixed)

Seems to no longer be an issue in Drupal 6 as well, as the setup described in the original post works correctly now.