I know that this issue is mentioned in the Drupal 7 Handbook for Boost as not tested yet, but I didn't find any relevant D7 issue, so I think it will help have this resolved to have an issue open.

I have a site in a subfolder (named... "site") and I have this .htaccess code on the main folder that removes the site name from the url:

RewriteRule ^$ site/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/site%{REQUEST_URI} -f
RewriteRule .* site/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* site/index.php?q=$0 [QSA]

I have also set the $base_url variable in settings.php to "http://www.mysite.com".

I have generated the Boost .htaccess rules and added them in the .htaccess that is inside the "site" folder:

  ### BOOST START ###

  # Allow for alt paths to be set via htaccess rules; allows for cached variants (future mobile support)
  RewriteRule .* - [E=boostpath:normal]

  # 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} (^/(admin|cache|misc|modules|sites|system|openid|themes|node/add|comment/reply))|(/(edit|user|user/(login|password|register))$) [OR]
  RewriteCond %{HTTPS} on [OR]
  RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
  RewriteCond %{ENV:REDIRECT_STATUS} 200
  RewriteRule .* - [S=3]

  # GZIP
  RewriteCond %{HTTP:Accept-encoding} !gzip
  RewriteRule .* - [S=1]
  RewriteCond /home/mysite/public_html/site/cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html,E=no-gzip:1]

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

  ### BOOST END ###

The cached files are generated in the /home/mysite/public_html/site/cache/normal/www.mysite.com/ folder.

The problem is that the cached files are never served to visitors. I suppose it's a matter of a small tweak to the .htaccess rules to make this work, but unfortunately, I couldn't figure out what exactly should I do nor to find out where it's looking for the existence of the cached files. Maybe it could be solved by creating a symbolic link to the cache folder?

Comments

bgm’s picture

Status: Active » Fixed

In here:

  # GZIP
  RewriteCond %{HTTP:Accept-encoding} !gzip
  RewriteRule .* - [S=1]
  RewriteCond /home/mysite/public_html/site/cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html,E=no-gzip:1]

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

You probably need to add the "site" directory, something such as:

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

Did you use the htaccess generator? Worked for me.

yannisc’s picture

Status: Fixed » Needs work

No, this didn't work.

Yes, I use the .htaccess generator. I tried adding the site/ folder in between, but there's no result. Even though the files are created in the cache folder.

klim_’s picture

Same problem for me..

bgm’s picture

The best way to debug this is to enable the rewritelog from mod_rewrite. Add this in your .htaccess:

RewriteLog /tmp/my-rewrite.log

Then do a single request to the site (it tends to generate a lot of output).

yannisc’s picture

I tried this, but unfortunately, I cannot debug based on the information provided. I don't have the expertise on this.

yannisc’s picture

Status: Needs work » Fixed

What finally worked for me was this: http://drupal.org/node/659042#comment-2644662

yannisc’s picture

Status: Fixed » Needs review
yannisc’s picture

To make it easier to test and use boost when serving the site from a subfolder, here is the instructions that are detailed in the previously mentioned post and worked for me:

1. Leave the inner .htaccess intact.
2. Put the .htaccess snippet that boost generates in the outer .htaccess and add the inner folder name at the RewriteCond and RewriteRule paths.

Here is my .htaccess that worked for me based on the above (change the folder with your installation folder):

 ### BOOST START ###

  # Allow for alt paths to be set via htaccess rules; allows for cached variants (future mobile support)
  RewriteRule .* - [E=boostpath:normal]

  # 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} (^/(admin|cache|misc|modules|sites|system|openid|themes|node/add|comment/reply))|(/(edit|user|user/(login|password|register))$) [OR]
  RewriteCond %{HTTPS} on [OR]
  RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
  RewriteCond %{ENV:REDIRECT_STATUS} 200
  RewriteRule .* - [S=3]

  # GZIP
  RewriteCond %{HTTP:Accept-encoding} !gzip
  RewriteRule .* - [S=1]
  RewriteCond %{DOCUMENT_ROOT}/cms/cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  RewriteRule .* cms/cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html,E=no-gzip:1]

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

  ### BOOST END ###

# Serve site from sub directory in web root
RewriteRule ^$ cms/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/cms%{REQUEST_URI} -f
RewriteRule .* cms/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* cms/index.php?q=$0 [QSA]
yannisc’s picture

Issue summary: View changes

minor fix.

jesse20142014’s picture

Can't get boost work .Please help.

some issue htacess

my drupal install in sub folder blogs

base_url=http://site.com/blogs

site.com/blogs