Categories
PHP Zend Framework

Zend Framework, Rewrite Rules, Apache

Most of the Zend Framework documentation I’ve read recommends a rewrite rule that looks something like this:

RewriteEngine on
RewriteRule !\.(swf|js|ico|gif|jpg|png|css)$ index.php

Why not use a more elegant rule that looks like this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php

This rule basically says: If it’s not an existing file, and it’s not an existing directory – pass the request through index.php.

This allows you far more flexibility when you want to host non-framework files, or a whole slew of other media types that are not listed in your apache configuration.

By Darryl Clarke

random text goes here, i guess