I want to use a Front Controller design pattern for my website, so I want to point everything to, let's say, index.php
.
Inside index.php
I want to split the REQUEST_URI
up into different things and decide what to do next from there.
How can I write my .htaccess
to do this?
Wordpress does this exactly:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
If you are running Apache version 2.2.17 or greater, I'd suggest FallbackResource
. I've found it to be slightly faster in these cases, i.e. Frontend Controller.