Rewrite Regular Files in Zend Framework- Error when using .htaccess

This was rather silly of me,

I was trying to add this line to my .htaccess:

RewriteRule ^free/download\.php /free/download/pdf [NC,L]

Not realizing that the Rewrite Conditions were completely negating my Rule.

The following will not Rewrite the URL if the Requested Filename is a regular file (example download.php)

RewriteCond %{REQUEST_FILENAME} !-f

The solution of course is to use the Zend Router to do the redirection, it’s one of those fore-head-smacking moments

I added this to my application.ini and away it went,

routes.freedownload.route = 'free/download.php'
routes.freedownload.defaults.controller = 'free'
routes.freedownload.defaults.action = 'download'
routes.freedownload.defaults.type = 'pdf'

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">