Posted by mmilano on September 17, 2008 at 1:57am
Is anyone using Boost with the rewrite conditions in an Apache conf vs. .htaccess? Boost works fine by default, but when I move the rerwite rules into apache, it does not.
I made the logical changes that I had to make from to the normal drupal rewrite by adding a slash before 'cache' on each rewrite rule.
Here's what I got.. If you have any suggestions, or could post your rewrite rules that work, I'd appreciate it.
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{HTTP_COOKIE} !DRUPAL_UID
RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0/index.html -f
RewriteRule ^(.)$ /cache/%{SERVER_NAME}/0/index.html [L]
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteCond %{REQUEST_URI} !^/cache
RewriteCond %{REQUEST_URI} !^/user/login
RewriteCond %{REQUEST_URI} !^/admin
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{HTTP_COOKIE} !DRUPAL_UID
RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0%{REQUEST_URI} -d
RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0%{REQUEST_URI}/index.html -f
RewriteRule ^(.)$ /cache/%{SERVER_NAME}/0/$1/index.html [L]
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteCond %{REQUEST_URI} !^/cache
RewriteCond %{REQUEST_URI} !^/user/login
RewriteCond %{REQUEST_URI} !^/admin
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{HTTP_COOKIE} !DRUPAL_UID
RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0%{REQUEST_URI}.html -f
RewriteRule ^(.)$ /cache/%{SERVER_NAME}/0/$1.html [L]
# BOOST END
# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule ^(.)$ /index.php?q=$1 [L,QSA]
Comments
Where in apache is this?
Where in your httpd.conf are these snippets located?
/etc/httpd/conf/httpd.conf <V
/etc/httpd/conf/httpd.conf
<VirtualHost :80>
ServerAdmin webmaster@example.com
DocumentRoot /var/www/example.com/public_html
ServerName example.com
ErrorLog /var/www/example.com/logs/error_log
CustomLog /var/www/example.com/logs/access_log common
Include conf/drupal.conf
</VirtualHost>
<Directory /var/www//public_html>
Options +Includes -Indexes
AllowOverride None
Order allow,deny
Allow from all
<Files ~ "^.ht">
Deny from all
</Files>
</Directory>
Then the rewrite rules I noted in my original post are in: /etc/httpd/conf/drupal.conf
The actual symptom is that only the index file is getting written to cache. No other file is written to cache unless I use the .htaccess.
Mike Milano
rewriterules in vhost
in the vhost, the active internal path does not include the document root yet, so you have to specify it in the rewriterule:
RewriteRule ^(.)$ boost/%{SERVER_NAME}/0/index.html [L]
becomes
RewriteRule ^(.)$ %{DOCUMENT_ROOT}/boost/%{SERVER_NAME}/0/index.html [L]
You will have to do this for each RewriteRule you have.
I did not bother to move drupal's regular rewrites into the vhost. Trying to keep drupal's .htaccess as little modified as possible, I just include it in the Directory context:
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
Include /var/www/.htaccess
That way, just my boost and site-specific rewrites are in the vhost context.
cheers,
-o
Thanks Oliver, that helped a
Thanks Oliver, that helped a ton. I've been grinding on this for the last couple days. Including from the Directory context works perfect.
Mike Milano