ENHANCEMENT STaticPublisher can now play nice with Subsites, you just need to set FilesystemPublisher::domain_based_caching to true. You also need to change your .htaccess to point all requests to sapphire/static-main.php, rather than main.php

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@81684 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Tom Rix 2009-07-13 04:42:48 +00:00
parent 39309b1e9a
commit d04c967558

33
static-main.php Normal file
View File

@ -0,0 +1,33 @@
<?php
$domainBasedCaching = true;
if ($domainBasedCaching) {
// Host -> cache dir mapping
if (file_exists('../subsites/host-map.php')) {
include_once '../subsites/host-map.php';
} else {
$subsiteHostmap = array();
}
// Look for the host, and find the cache dir
$host = str_replace('www.', '', $_SERVER['HTTP_HOST']);
$cacheDir = isset($siteHostmap[$host]) ? $siteHostmap[$host] : $siteHostmap['default'];
} else {
$cacheDir = '';
}
// Look for the file in the cachedir
$file = preg_replace('/[^a-zA-Z0-9]/si', '_', trim($_SERVER['REQUEST_URI'], '/'));
$file = $file ? $file : 'index';
if (file_exists('../cache/'.$cacheDir.'/'.$file.'.html')) {
echo file_get_contents('../cache/'.$cacheDir.'/'.$file.'.html');
} elseif (file_exists('../cache/'.$cacheDir.'/'.$file.'.php')) {
include_once '../cache/'.$cacheDir.'/'.$file.'.php';
} else {
// No cache hit... fallback!!!
include 'main.php';
}
?>