Re: [SMARTY] Configuring apache to fallback to a default template handler
| From: | Mark Rogers | Date: | Mon, 05 Apr 2004 15:52:10 +0000 |
| Subject: | Re: [SMARTY] Configuring apache to fallback to a default template handler | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-11232@lists.php.net to get a copy of this message | ||
I did something very similar recently, with many of the similar problems.
One specific point, though:
> 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.
If you have a url
/default.php/somepage.html
.. it should go through default.php.
If you want /default/somepage.html to do the same thing, mod_rewrite can do
this, but to be honest if /default.php/somepage.html is enough I'd go with
that.
NB:
Be careful that you don't end up making all your templates source available
through your script. Either make sure all the static pages are in a separate
directory so there's no potential problem (and be sure to catch
/default.php/../somepage.html etc) or check the page requested. Otherwise
any benefit from leaving the templates out of htdocs is lost.
PS:
An example mod_rewrite I've used before is:
RewriteEngine on
RewriteRule ^/products/([^\.]*)(\.html)$ /products.php?product=$1 [QSA]
So /products/widget.html becomes products.php?product=widget. The QSA is
important otherwise you won't get the rest of the URL appended (eg
/products/widget.html?x=y would lose the x=y on rewriting without the [QSA],
which completely screws URL-based session handling amongst other things).
--
Mark Rogers,
More Solutions Ltd