Hi there,

We have a rather large drupal 6 multisite installation, that utilises subfolders rather than sub domains. I noticed when reading the features of boost, it said it supports multisite installs, and subfolder installs.

My question is, has anyone had any luck getting a multisite subfolder installation working with boost?

The current rewrite rules in order to get the this working with apache:

Alias /phonebook /opt/drupalfiles/vhosts/intranet

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/phonebook/(.*)$
RewriteRule ^(.*)$ /phonebook/index.php?q=$1 [L,QSA]

Any help would be appreciated

Comments

mikeytown2’s picture

Can I get a overview of how everything fits together? I haven't tested multisites via sub folders. So you have to change core's htaccess rules in order to get this working, correct?

wiifm’s picture

Hi Mike,

Correct, core drupal .htaccess does not cope with multisites under sub folders.

The tutorial I followed a while back that inspired me to do this was here - http://www.drupalcoder.com/story/205-drupal-multisite-in-subfolders.

In essence for every site (in the sub folder), you need 1x Alias apache directive and 1x rewrite rule (similiar to core drupal)

We are currently trying various combinations of rewrite rules to try and get boost to work. Items that may be of interest, when visiting the PHP info page in drupal for example, the REQUEST_URI variable still contains the initial sub folder:

REQUEST_METHOD 	GET
QUERY_STRING 	q=admin/reports/status/php
REQUEST_URI 	/phonebook/admin/reports/status/php
SCRIPT_NAME 	/phonebook/index.php 

hope this helps, and thanks for the fast response

mikeytown2’s picture

first up; this rule should handle all your sub dirs. Untested, but should work.

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/(.+)/(.*)$
  RewriteRule ^ /%1/index.php?q=%2 [L,QSA]

Secondly I need some example URLs, sites dir used & file generated. Example:
URL: example.com/subdir1/front
DIR: /var/www/sites/mydrupalsite.com.subdir1/
FILE: /var/www/cache/normal/subdir1/front_.html

wiifm’s picture

Hi Mike,

URL: http://intrastg01.ird.govt.nz/phonebook/search/apachesolr_search
DIR: /opt/drupalfiles/vhosts/intranet/sites/intrastg01.ird.govt.nz.phonebook
FILE: /opt/drupalfiles/vhosts/intranet/cache/normal/intrastg01.ird.govt.nz/phonebook/search/apachesolr_search_.html

So it looks like boost is creating the static files

wiifm’s picture

Note -

DIR is actually a symlink pointing at

/opt/drupalfiles/vhosts/intranet/sites/phonebook

The above path is the actual directory.

mikeytown2’s picture

One more bit of info; What does this spit out on your server?

echo $_SERVER['DOCUMENT_ROOT'] . ' - ' . $_SERVER['HTTP_HOST'] . ' - ' . $_SERVER['REQUEST_URI'];
wiifm’s picture

I'll do you one better, this is the output of phpinfo();

REDIRECT_STATUS 	200
HTTP_HOST 	intrastg01.ird.govt.nz
HTTP_USER_AGENT 	Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
HTTP_ACCEPT 	text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_LANGUAGE 	en-us,en;q=0.5
HTTP_ACCEPT_ENCODING 	gzip,deflate
HTTP_ACCEPT_CHARSET 	ISO-8859-1,utf-8;q=0.7,*;q=0.7
HTTP_KEEP_ALIVE 	115
HTTP_CONNECTION 	keep-alive
HTTP_REFERER 	http://intrastg01.ird.govt.nz/phonebook/admin/reports/status
SERVER_SIGNATURE 	<address>Apache/2.2.10 (Linux/SUSE) Server at intrastg01.ird.govt.nz Port 80</address>
SERVER_SOFTWARE 	Apache/2.2.10 (Linux/SUSE)
SERVER_NAME 	intrastg01.ird.govt.nz
SERVER_ADDR 	10.0.22.42
SERVER_PORT 	80
REMOTE_ADDR 	10.32.149.58
DOCUMENT_ROOT 	/opt/drupalfiles/vhosts/intranet
SCRIPT_FILENAME 	/opt/drupalfiles/vhosts/intranet/index.php
REMOTE_PORT 	61508
REDIRECT_QUERY_STRING 	q=admin/reports/status/php
REDIRECT_URL 	/phonebook/admin/reports/status/php
GATEWAY_INTERFACE 	CGI/1.1
SERVER_PROTOCOL 	HTTP/1.1
REQUEST_METHOD 	GET
QUERY_STRING 	q=admin/reports/status/php
REQUEST_URI 	/phonebook/admin/reports/status/php
SCRIPT_NAME 	/phonebook/index.php
mikeytown2’s picture

I think the htaccess generator should work for you.

Go to the very bottom of admin/settings/performance/boost and change Document Root: to "/opt/drupalfiles/vhosts/intranet"

Then go here and try out the rules. Copy paste in
admin/settings/performance/boost-rules

sunshinewellington’s picture

Hi Mike,

I'm Vincent, working with Sean! Implemented your suggestion of changing the document root, here's
below the resulting code.

  ### BOOST START ###
  AddDefaultCharset utf-8
  <FilesMatch "(\.html|\.html\.gz)$">
    <IfModule mod_headers.c>
      Header set Expires "Sun, 19 Nov 1978 05:00:00 GMT"
      Header set Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
    </IfModule>
  </FilesMatch>
  <IfModule mod_mime.c>
    AddCharset utf-8 .html
    AddCharset utf-8 .css
    AddCharset utf-8 .js
    AddEncoding gzip .gz
  </IfModule>
  <FilesMatch "(\.html|\.html\.gz)$">
    ForceType text/html
  </FilesMatch>
  <FilesMatch "(\.js|\.js\.gz)$">
    ForceType text/javascript
  </FilesMatch>
  <FilesMatch "(\.css|\.css\.gz)$">
    ForceType text/css
  </FilesMatch>

  # Gzip Cookie Test
  RewriteRule boost-gzip-cookie-test\.html  cache/perm/boost-gzip-cookie-test\.html\.gz [L,T=text/html]

  # GZIP - Cached css & js files
  RewriteCond %{HTTP_COOKIE} !(boost-gzip)
  RewriteCond %{HTTP:Accept-encoding} !gzip
  RewriteRule .* - [S=2]
  RewriteCond /opt/drupalfiles/vhosts/intranet/phonebook/cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.css\.gz -s
  RewriteRule .* cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.css\.gz [L,QSA,T=text/css]
  RewriteCond /opt/drupalfiles/vhosts/intranet/phonebook/cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.js\.gz -s
  RewriteRule .* cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.js\.gz [L,QSA,T=text/javascript]

  # NORMAL - Cached css & js files
  RewriteCond /opt/drupalfiles/vhosts/intranet/phonebook/cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.css -s
  RewriteRule .* cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.css [L,QSA,T=text/css]
  RewriteCond /opt/drupalfiles/vhosts/intranet/phonebook/cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.js -s
  RewriteRule .* cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.js [L,QSA,T=text/javascript]

  # Caching for anonymous users
  # Skip boost IF not get request OR uri has wrong dir OR cookie is set OR request came from this server OR https request
  RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [OR]
  RewriteCond %{REQUEST_URI} (^/phonebook/(admin|cache|misc|modules|sites|system|openid|themes|node/add))|(/(comment/reply|edit|user|user/(login|password|register))$) [OR]
  RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
  RewriteCond %{HTTP:Pragma} no-cache [OR]
  RewriteCond %{HTTP:Cache-Control} no-cache [OR]
  RewriteCond %{HTTPS} on
  RewriteRule .* - [S=3]

  # GZIP
  RewriteCond %{HTTP_COOKIE} !(boost-gzip)
  RewriteCond %{HTTP:Accept-encoding} !gzip
  RewriteRule .* - [S=1]
  RewriteCond /opt/drupalfiles/vhosts/intranet/phonebook/cache/normal/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html\.gz -s
  RewriteRule .* cache/normal/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html\.gz [L,T=text/html]

  # NORMAL
  RewriteCond /opt/drupalfiles/vhosts/intranet/phonebook/cache/normal/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/normal/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]

  ### BOOST END ###

Tried this and the Apache still not rewriting to the boost static file.

Also, noticed that the cache folder is located at:
/opt/drupalfiles/vhosts/intranet/cache NOT
/opt/drupalfiles/vhosts/intranet/phonebook/cache

We've included this into the vhosts configuration instead of .htaccess, does this make it different?

mikeytown2’s picture

# file output from boost
/opt/drupalfiles/vhosts/intranet/cache/normal/intrastg01.ird.govt.nz/phonebook/search/apachesolr_search_.html

# generated rules
/opt/drupalfiles/vhosts/intranet/phonebook/cache/normal/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html

New rules with phonebook removed. This means that one set of rules should work for all your sub directories.

  ### BOOST START ###
  AddDefaultCharset utf-8
  <FilesMatch "(\.html|\.html\.gz)$">
    <IfModule mod_headers.c>
      Header set Expires "Sun, 19 Nov 1978 05:00:00 GMT"
      Header set Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
    </IfModule>
  </FilesMatch>
  <IfModule mod_mime.c>
    AddCharset utf-8 .html
    AddCharset utf-8 .css
    AddCharset utf-8 .js
    AddEncoding gzip .gz
  </IfModule>
  <FilesMatch "(\.html|\.html\.gz)$">
    ForceType text/html
  </FilesMatch>
  <FilesMatch "(\.js|\.js\.gz)$">
    ForceType text/javascript
  </FilesMatch>
  <FilesMatch "(\.css|\.css\.gz)$">
    ForceType text/css
  </FilesMatch>

  # Gzip Cookie Test
  RewriteRule boost-gzip-cookie-test\.html  cache/perm/boost-gzip-cookie-test\.html\.gz [L,T=text/html]

  # GZIP - Cached css & js files
  RewriteCond %{HTTP_COOKIE} !(boost-gzip)
  RewriteCond %{HTTP:Accept-encoding} !gzip
  RewriteRule .* - [S=2]
  RewriteCond /opt/drupalfiles/vhosts/intranet/cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.css\.gz -s
  RewriteRule .* cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.css\.gz [L,QSA,T=text/css]
  RewriteCond /opt/drupalfiles/vhosts/intranet/cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.js\.gz -s
  RewriteRule .* cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.js\.gz [L,QSA,T=text/javascript]

  # NORMAL - Cached css & js files
  RewriteCond /opt/drupalfiles/vhosts/intranet/cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.css -s
  RewriteRule .* cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.css [L,QSA,T=text/css]
  RewriteCond /opt/drupalfiles/vhosts/intranet/cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.js -s
  RewriteRule .* cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.js [L,QSA,T=text/javascript]

  # Caching for anonymous users
  # Skip boost IF not get request OR uri has wrong dir OR cookie is set OR request came from this server OR https request
  RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [OR]
  RewriteCond %{REQUEST_URI} (^/phonebook/(admin|cache|misc|modules|sites|system|openid|themes|node/add))|(/(comment/reply|edit|user|user/(login|password|register))$) [OR]
  RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
  RewriteCond %{HTTP:Pragma} no-cache [OR]
  RewriteCond %{HTTP:Cache-Control} no-cache [OR]
  RewriteCond %{HTTPS} on
  RewriteRule .* - [S=3]

  # GZIP
  RewriteCond %{HTTP_COOKIE} !(boost-gzip)
  RewriteCond %{HTTP:Accept-encoding} !gzip
  RewriteRule .* - [S=1]
  RewriteCond /opt/drupalfiles/vhosts/intranet/cache/normal/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html\.gz -s
  RewriteRule .* cache/normal/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html\.gz [L,T=text/html]

  # NORMAL
  RewriteCond /opt/drupalfiles/vhosts/intranet/cache/normal/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/normal/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]

  ### BOOST END ###

Vhosts shouldn't make a difference. If it does let me know.

wiifm’s picture

It works!

Thanks Mike, this seems to have cleared things up, anonymous users now get boost cached files instead of hitting drupal ;)

Any chance a tweak could be made to boost to enable boost to work multisite subfolder installations out of the box ?

Thanks
Sean

mikeytown2’s picture

The main thing is DOCUMENT_ROOT is not set correctly because of the alias usage in your apache configuration. You had to change the htaccess rules to get this working correctly; I don't want to spend the time to program up a way to correctly detect non standard install like this. In terms of Boost, another option is to define the document root as an environmental variable like this

 RewriteRule .* - [E=boostdocroot:/opt/drupalfiles/vhosts/intranet]

There's a good chance the rules generation would have picked this up and given it to you as an option then. It would show up like %{ENV:boostdocroot}. The new rules using this would look like this.

  ### BOOST START ###
  AddDefaultCharset utf-8
  <FilesMatch "(\.html|\.html\.gz)$">
    <IfModule mod_headers.c>
      Header set Expires "Sun, 19 Nov 1978 05:00:00 GMT"
      Header set Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
    </IfModule>
  </FilesMatch>
  <IfModule mod_mime.c>
    AddCharset utf-8 .html
    AddCharset utf-8 .css
    AddCharset utf-8 .js
    AddEncoding gzip .gz
  </IfModule>
  <FilesMatch "(\.html|\.html\.gz)$">
    ForceType text/html
  </FilesMatch>
  <FilesMatch "(\.js|\.js\.gz)$">
    ForceType text/javascript
  </FilesMatch>
  <FilesMatch "(\.css|\.css\.gz)$">
    ForceType text/css
  </FilesMatch>
  # Setup Doc Root
  RewriteRule .* - [E=boostdocroot:/opt/drupalfiles/vhosts/intranet]

  # Gzip Cookie Test
  RewriteRule boost-gzip-cookie-test\.html  cache/perm/boost-gzip-cookie-test\.html\.gz [L,T=text/html]

  # GZIP - Cached css & js files
  RewriteCond %{HTTP_COOKIE} !(boost-gzip)
  RewriteCond %{HTTP:Accept-encoding} !gzip
  RewriteRule .* - [S=2]
  RewriteCond %{ENV:boostdocroot}/cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.css\.gz -s
  RewriteRule .* cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.css\.gz [L,QSA,T=text/css]
  RewriteCond %{ENV:boostdocroot}/cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.js\.gz -s
  RewriteRule .* cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.js\.gz [L,QSA,T=text/javascript]

  # NORMAL - Cached css & js files
  RewriteCond %{ENV:boostdocroot}/cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.css -s
  RewriteRule .* cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.css [L,QSA,T=text/css]
  RewriteCond %{ENV:boostdocroot}/cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.js -s
  RewriteRule .* cache/perm/%{HTTP_HOST}%{REQUEST_URI}_\.js [L,QSA,T=text/javascript]

  # Caching for anonymous users
  # Skip boost IF not get request OR uri has wrong dir OR cookie is set OR request came from this server OR https request
  RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [OR]
  RewriteCond %{REQUEST_URI} (^/phonebook/(admin|cache|misc|modules|sites|system|openid|themes|node/add))|(/(comment/reply|edit|user|user/(login|password|register))$) [OR]
  RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
  RewriteCond %{HTTP:Pragma} no-cache [OR]
  RewriteCond %{HTTP:Cache-Control} no-cache [OR]
  RewriteCond %{HTTPS} on
  RewriteRule .* - [S=3]

  # GZIP
  RewriteCond %{HTTP_COOKIE} !(boost-gzip)
  RewriteCond %{HTTP:Accept-encoding} !gzip
  RewriteRule .* - [S=1]
  RewriteCond %{ENV:boostdocroot}/cache/normal/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html\.gz -s
  RewriteRule .* cache/normal/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html\.gz [L,T=text/html]

  # NORMAL
  RewriteCond %{ENV:boostdocroot}/cache/normal/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/normal/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]

  ### BOOST END ###

Anyway long story short using symlinks would probably work better.
http://drupal.org/getting-started/6/install/multi-site look under "Subdirectory multi-site"

wiifm’s picture

Status: Active » Fixed

Thanks for all your help Mike,

You are right the symlink in the root of the drupal install pointing the 'subfolder' back to the base would avoid all of these alias commands and boost would just work.

Am very happy with the workaround provided though, and we will investigate the new environment variable to see if this can help

Thanks again
Sean

Status: Fixed » Closed (fixed)

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

plaverty’s picture

Status: Closed (fixed) » Active

Ok, I'll be the latest to ask about this here. We're running a multi-site instance with subdirectories and we can't get boost to write the normal files. We see it writing the js and css, but not the content files. One thing that we see when we run cron is we get the warning that it's not a good idea to have safe mode on while running boost. But we have safe mode off for the entire server. We're not sure how that is getting triggered, or if that is even the trouble. My cache dir is writeable by the web server. My BOOST - HTML - DEFAULT MAXIMUM CACHE LIFETIME: is set to 1 minute.

Anything else obvious that I should be checking for?

Thanks!

plaverty’s picture

Status: Active » Closed (fixed)

Figured it out...