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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

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


Go to End


3665 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 static publisher 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 .htaccess file 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