Hi all,
I have tried for long time but unfortunately I didn't get any success.

I have Drupal installed in a sub folder ('cms') and after many tries I found out that if I set the $base_url variable, then Boost does not serve cached pages.

If I omit the $base_url variable, pages are served cached by Boost, but internal links will show the subdirectory path in the url.

These are the settings:

1) .htaccess in the root of the server:

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

2) .htaccess in the subfolder where Drupal is installed:

  # NORMAL
  RewriteCond /var/www/vhosts/domain.com/httpdocs/cms/cache/normal/www.domain.com%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/normal/www.domain.com%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]

3) settings.php

$base_url = 'http://www.domain.com';

As I said, if $base_url is set, then Boost does not serve cached pages, but internal links are written as they are supposed to be (if I go to http://www.domain.com/admin I am correctly redirected to the admin interface of Drupal), but if I comment the $base_url variable, cached pages are served by Boost, but internal links will show up the 'cms' subdirectory.

Any idea why this is happening?

Thanks a lot.

Comments

Aibu’s picture

Tried also with dev but no luck so far.

Anyone has Boost running in a Drupal installed on a subfolder? Have you experienced the same issue?

Thanks a lot.

jho1086’s picture

subscribing

anavarre’s picture

Subscribing

cantidubi’s picture

Subscribing

tfo’s picture

+1

newtonpage’s picture

subscribing

justcaldwell’s picture

Same issue. Subscribing.

justcaldwell’s picture

When the $base_url is set as described above, Boost will write cache files to a directory path that does not include 'cms'. But the .htaccess rewrite rules generated by Boost continue 'looking' for files at a path that includes 'cms'. For example - given a request for http://www.domain.com/foo/bar

Boost writes the cache file at

  cache/normal/www.domain.com/foo/bar/_.html

But the .htaccess RewriteCond still 'looks' for it at

  cache/normal/www.domain.com/cms/foo/bar/_.html

Details

By setting the $base_url, you've told Drupal/Boost to stop using the cms directory. The Boost .htaccess rules, however, rely on %{REQUEST_URI} provided by the server; which, in this scenario, still contains 'cms' in the path.

Given the same request http://www.domain.com/foo/bar - after it's rewritten by the rule at the root level, %{REQUEST_URI} becomes /cms/foo/bar/.

# NORMAL
  RewriteCond /var/www/vhosts/domain.com/httpdocs/cms/cache/normal/www.domain.com%{REQUEST_URI}_%{QUERY_STRING}\.html -s
                                                                                 ^^^^^^^^^^^^^^ = /cms/foo/bar

This is checking for existence of the file in the wrong directory.

One solution

Modify the .htaccess rewrites to use a portion of REQUEST_URI (minus '/cms').

# NORMAL
  RewriteCond %{REQUEST_URI} (\/cms)(.*)$
# %2 now contains the path without /cms -- replace instances of ${REQUEST_URI} with %2
  RewriteCond /var/www/vhosts/domain.com/httpdocs/cms/cache/normal/www.domain.com%2_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/normal/www.domain.com%2_%{QUERY_STRING}\.html [L,T=text/html]

# original rules
# RewriteCond /var/www/vhosts/domain.com/httpdocs/cms/cache/normal/www.domain.com%{REQUEST_URI}_%{QUERY_STRING}\.html -s
# RewriteRule .* cache/normal/www.domain.com%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]

It seems to me that this – or some flavor of it – should work, but I can't confirm as it generates 500 errors in my environment. I think (hope) I've got a server config issue. Got it working with the modified rewrites above.

justcaldwell’s picture

To follow up: Turns out I did have some config issues. Once those got cleared up, the solution above worked for me.

ecalcerrada’s picture

Hi justcaldwell,

for the first time I've understood what the problem I had with Boost was. In effect I've also Drupal installed in a subdirectory (in my case "drupal", instead of "cms"), and $base_url set, but I've tried to apply your solution and that doesn't work for me. In Status Report there was an error message indicating that ".htaccess file does not contain or match the boost specific rewrite rules, or the rewrite rules have changed".

I had configured .htacces like this (I'm using also gzip compression, so I added that section):

  # GZIP
  RewriteCond %{HTTP_COOKIE} !(boost-gzip)
  RewriteCond %{HTTP:Accept-encoding} !gzip
  RewriteRule .* - [S=1]
  RewriteCond %{REQUEST_URI} (\/drupal)(.*)$
  # %2 now contains the path without /drupal -- replace instances of %{REQUEST_URI} with %2
  RewriteCond /web/htdocs/www.example.com/drupal/cache/normal/www.example.com%2_%{QUERY_STRING}\.html\.gz -s
  RewriteRule .* cache/normal/www.example.com%2_%{QUERY_STRING}\.html\.gz [L,T=text/html,E=no-gzip:1]

  # NORMAL
  RewriteCond %{REQUEST_URI} (\/drupal)(.*)$
  # %2 now contains the path without /drupal -- replace instances of %{REQUEST_URI} with %2
  RewriteCond /web/htdocs/www.example.com/drupal/cache/normal/www.example.com%2_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/normal/www.example.com%2_%{QUERY_STRING}\.html [L,T=text/html]

Do you know what is wrong with it? I wonder if I should change %2 for another value, or maybe don't repeat the same %2 value both in # GZIP and in # NORMAL sections. (Really I don't know what %2 means or where it comes from...)

Any idea?

Thanks a lot!

kirtimansharma’s picture

subscribe

unc0nnected’s picture

Above solution doesn't work for me unfortunately

+subscribe

reswild’s picture

@ecalcerrada: "%2" is a backreference to the second grouped part (that is, the stuff in the parentheses) of the pattern from the last matched RewriteCond, so it is no problem with repeating it several times.

But if you are going to mess around with htaccess rewrite rules anyway, then I think a better solution would be to not rely on $base_url in the first place, but instead set up a rewrite rule to point your domain to the right folder.

jesse20142014’s picture

Same issue. Subscribing.

borrico1965’s picture

Hi,
Have you tried implementing solution made by dagomar found here, https://www.drupal.org/node/1459690#comment-7261264?
It's a comment in a post entitled, Boost 7.x: installation instructions.
It worked for me, it might help solve your problem too.

avpaderno’s picture

Issue tags: -boost, -$base_url
avpaderno’s picture

Status: Active » Closed (outdated)

I am closing this issue, as Drupal 6 is no longer supported.