As a reminder, instead of using a web server such as Apache you can run TwigExpress using PHP on the command line:
$ php --server localhost:8000 twigexpress.pharBut if you do want to use Apache, you can:
- Put
twigexpress.pharin your web root. - Create a
.htaccessfile with this content:
## Multiviews can create issues with filename.ext.twig
## patterns (when accessed as filename.ext).
Options -Indexes -Multiviews
## Treat .phar as PHP
AddHandler application/x-httpd-php .phar
# Serve all requests with TwigExpress
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# pass-through if another rewrite rule has been applied already
# (simpler with Apache 2.3+, use a [L,END] flag on the RewriteRule)
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
# avoid redirection loops
RewriteCond %{REQUEST_URI} !twigexpress\.phar
RewriteRule (.*) twigexpress.phar/index.php [L]
</IfModule>Reminder: TwigExpress is not made for production sites, only for local development. Using it on a live server is a security risk.