Configuring apache to fallback to a default template handler

From: Date: Mon, 05 Apr 2004 15:17:27 +0000
Subject: Configuring apache to fallback to a default template handler
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11230@lists.php.net to get a copy of this message
Hi everyone, I've got a question, that I'll try asking here first, in the hope that another fellow Smarty user has tried this. (If not, I'll move on to a more appropriate apache/php mailing list). I have the following PHP/Smarty project structure: myapp/
   htdocs/    - public access document root
       default.php   - default template handler
       ...other php scripts...
   templates/    - smarty templates
       about/
          company.html
Given a URL, eg: http://www.things-n-stuff.com/about/company I want to check for files in the following order: 1, htdocs/*.php - if this exists then handle with mod_php, as normal (eg. htdocs/about/company.php) 2, templates/*.html - if this exists then passthru to htdocs/default.php (eg. templates/about/company.html) 3, otherwise, perform a normal 404 error via Apache. I want default.php to act purely as a handler, it receives the request with the original URL including fragment and query string intact. It will determine which template to fetch from $_SERVER["REQUEST_URI"], and all $_REQUEST/$_GET/$_POST vars are assigned as usual. It sets up Smarty and displays the template (wrapped in the usual gubbins, ie side bars, navigation, header, footer etc.) At present I'm duplicating (or sym-linking) the default.php file for each template that requires no special preprocessing. I've tried using the apache directive: ErrorDocument 404 /default.php But the default.php script receives the request as if redirected, so the php variables aren't as expected, ie. none of the query string values have been extracted into $_REQUEST/$_GET etc. mod_rewrite may be an option, anyone an expert on this? I'm already using some simple rules for virtual hosting (can post them if anyone can suggest how to integrate the above idea with them). Alternatively, could Apache be configured to pass all requests within a certain directory to a single PHP script? default.php would then perform the three stages above. Any ideas? (or to whom I could redirect this question) Cheers -- Mark Gibson <gibsonm |AT| cromwell |DOT| co |DOT| uk> Web Developer & Database Admin Cromwell Tools Ltd. Leicester, England.

« previous php.smarty.general (#11230) next »