ZF-25: Zend_Controller_Router breaks on IIS due to differences between IIS and Apache (TRAC#2)


Hi friends,

When I was making a test running Zend Framework on IIS Server I've stopped by a problem. After some tests I've found a bug at this line: The bug occurs because when you put as your's url the apache server returns, but IIS returns or your default page.

That action causes a crash at the 71th line of library\zend\controllers\route.php, where strlen($controller) now will not return 0 but 9 (if index is your default page) and 'index.php' isn't a controller, then noRouteAction will be selected, returning to index.php, this error will be again and will return to index again.... and thus successively.

sorry by disturb, and congratulations for the good job,

Bruno Eduardo de resende Oliveira


05/05/06 08:41:33: Modified by

I'm running ZF on IIS. It functions great with a small workaround. You have to install Isapi_Rewrite ( to get mod_rewrite-like functionality in IIS. Then in Zend_Controller_Router you only need to change line 52 in Zend/Controller/Router.php from

$path = $_SERVER['REQUEST_URI'];


$path = strtolower($_SERVER['HTTP_X_REWRITE_URL']);

Isapi_Rewrite sets the HTTP_X_REWRITE_URL $_SERVER variable to be what REQUEST_URI would be if you were running on Apache and using mod_rewrite.

I hope that helps. 06/12/06 06:22:42: Modified by Link

Could you provide working isapi rewrite rules? I'm trying those and they don't seem to work on my setup:

RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^.*$ index.php

And this also doesn't work:

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

I have found a working rewrite rule: RewriteRule (?!.(js|ico|gif|jpg|png|css|swf))$ index.php

Router works as expected. Without any changes to the code.