Zend Framework & Flash

Here’s a quick little “gotcha” when using the Zend PHP Framework:

If you plan on using Flash at all (i.e., SWF or FLV files) be sure to append the necessary extensions the .htaccess file in the “public” folder to the rewrite rule:

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

Note the added “swf” and “flv” extensions. Otherwise access to these files will return an error. Firebug (if you use it) will say that the files are being loaded (200 OK), but if you look at the response, it’s the error page not the actually requested file that is being returned.

Granted, this isn’t exclusive to the Zend Framework – it’s a result of the .htaccess configuration (regardless of which framework/engine you use); but it’s just something to keep in mind.

Update:

Here’s a better declaration (via: http://framework.zend.com/manual/en/zend.application.quick-start.html):

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]