Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS /

.htaccess %{DOCUMENT_ROOT} problem (for static publisher extension)


Reply


2687 Views

Avatar
Anatol

126 Posts

25 March 2009 at 7:55pm

Edited: 25/03/2009 7:58pm

Hi,

just if anyone ever comes across the same problem: here is a question and it comes with the answer. I hope it will save someone a bit of frustration.

I moved a Silverstripe site with [url=http://doc.silverstripe.com/doku.php?id=staticpublisher]static publisher[/url] enabled from my development server to a client's hosted web space. After the shift the static publisher did not work. The cached pages were there but the response header always showed PHP, not HTML - but I was sure the [url=http://open.silverstripe.com/browser/modules/cms/trunk/code/staticpublisher/htaccess_example_rsyncsingleserver].htaccess file[/url] was correct.

The simple solution was that this host did not know the %{DOCUMENT_ROOT} variable (or they disabled it, I don't know), and so I had to edit .htaccess with a hardcoded path. If that's the case with your hosting company just replace any %{DOCUMENT_ROOT} with

/absolute/path/from/root/to/cache/%1.html -f

Not nice, but in my case the only way that worked.

How to get the path? Just copy and paste the DOCUMENT_ROOT variable from the Environment or PHP Variables section of your phpinfo().

It's always worth checking the response header if you use the static publisher (I use the Firefox web developer addon for that).

In this particular case I use the static publisher not because of high traffic but because the host is extreeeeeemly slow in serving PHP pages. I knew there was a catch when the client told me about his super-cheap hosting plan...

Cheers!
Anatol