Zend Framework on IIS with IIRF

Zend Framework can run on Apache, Microsoft IIS and Lighttpd. We have been running Zend Framework on all our project on Apache web server. However, one of our project informs us late about the server and that it was Windows Server 2003 and Microsoft IIS 6. We have no choice but to make Zend Framework run on IIS. It was tricky, but it works with almost no issues so far.


Because of so many comments that seems like the readers are a bit confused, I have updated this post and edited parts to enhance clarity and also to integrate with the current theme. I apologize for my weird writing style.

Zend Framework’s Flexibility

Zend Frameworks search engine friendly URL actually does not need Apache’s mod_rewrite. It only needs to run its index.php and all those parameters are processed using its internal rewriting, whatever you may call it. For example:

http://localhost/myproject/login <-- is the same as http://localhost/myproject/index.php/login

The first one makes use of URL rewriting via Apache (if you are on Apache) and automatically forward all requests to index.php.

The second doesn’t use Apache’s mod_rewrite and only process the parameters by its own. Using that observation, Zend Framework can live without mod_rewrite. That should also be true to Microsoft’s IIS.

IIS with ISAPI_Rewrite

Before you ever proceed, make sure you have installed PHP to your IIS. I will not cover that topic for now, so go ahead and grab the manual or search the net. It is actually not that difficult.

When I try the project on IIS, it only works on the main page. Thus, the index.php without any further parameters. Accessing index.php/login will issue 404 error. So we conclude that IIS does not treat the /login as parameter, but instead it treats that as a file.

A workaround on this rewrite issue is to use third party solutions. One of them is ISAPI_Rewrite by Helicon Tech. It actually works nice, however, the actual server is using Virtual Websites on IIS and the free version does not support it. Buying the Full Version is not an option.

Another third party solution is the Ionic’s ISAPI Rewrite Filter. It does URL rewriting that is small, free and easy to use. It is not that full of features but the basic feature is just what Zend Framework needs.

Download the Ionic’s ISAP Rewrite Filter (IIRF) here. You will only need the file: IsapiRewrite4.dll. Copy the file IsapiRewrite4.dll to anywhere on the server, but I suggest to put it on C:\WINDOWS\system32\inetsrv.

On the same folder, create the file: IsapiRewrite4.ini since the dll will look for this file at startup. Put the following content.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^/(.*)$ /index.php?q=$1 [I,L]
RewriteRule ^/(.*)$ /index.php [L,I,U]

NOTE: Please note that the above rewrite rules will work only for projects that are directly under the root of the website/virtual website. If it is under a subfolder, then you need to tweak the rules to make it work.

Configurations, configurations

First, we need to set the document root to the public directory of your Zend Framework application. For example, if you save your project to c:/inetpub/wwwroot/zfapp, set the document root to c:/inetpub/wwwroot/zfapp/public. This can be done on the website property on IIS under the Home Directory tab (based on IIS 6, others may differ).

Set the two files: IsapiRewrite4.ini and IsapiRewrite4.dll permission. Make sure the IIS user’s IUSR_HOSTNAME and IWAM_HOSTNAME for Windows XP. On Windows Server 2003, the username is different. I think it was IIS_WPG or something like that. If you can’t find the correct username, look at InetPub folder and look at the permissions to give you the clues.

Only set the read access. Don’t grant write.


Open IIS and go to your website’s properties.


Goto ISAPI Filters tab. Add the Ionic Rewriter to the filters.


After you have done adding the filter, it should more or less look the the image above.


Restart IIS and everything should work just like you were on Apache.

This entry was posted in IIS, Zend Framework and tagged , , , , . Bookmark the permalink.

30 Responses to Zend Framework on IIS with IIRF

  1. rodel says:

    very nice article. it helps me a lot to setup our server. thanx a lot

  2. Lysender says:

    Thanks for dropping by. Sorry I forgot logging in to my blog, that’s why your comment is pending for a week.

    Good thing it helps you.

  3. Yon says:

    Great article! Anyway, still have a problem adding GET parameters to the URI in this way: http://example.com/controller/action?param1=value1&param2=value2. Works fine on APACHE environment but crashes on IIS, any recommendation?

  4. Lysender says:

    I don’t have experience using GET in Zend Framework, not even on Apache. I only use params after the action parameter. Like this one:


  5. Yon says:

    Problem solved using correctly the rewrite rules:
    RewriteRule ^/(.*)\?(.*)$ /index.php?$2 [L,I,U]
    This way works OK!
    Thanks again!

  6. Lysender says:

    Wow, good thing you’ve solved it.

    Regex Sucks MeME

  7. Artem says:

    IIS did’t load .dll till I put both files to the inetpub folder.

  8. Lysender says:

    Maybe you haven’t set the permissions to the appropriate IIS user. Anyway, good thing it works by the tricks you’ve done.

  9. Maggi says:

    when i downloaded IonicIsapiRewriter- i got IIRF.dll but not IsapiRewrite4.dll as you have mentioned.

    I have tried all the possible ways but it didnt work. Help Please.
    Am using win2003 iis6

  10. lysender says:

    Hi Maggi,

    This post was a year ago so maybe the IIRF guys updated their library and rename the DLL. Try using the IIRF.dll if it works. If not, I have uploaded the IsapoRewrite4.dll for you.


  11. Maggi says:

    Thanks for your prompt response. I will try this.

  12. Maggi says:

    I have done all the changes that you have mentioned above(add ini and dll) and given permissions. Placed the content in ini as mentioned above. Removed the .htaccess file which I got from default zend framework project(Does it need to be removed????).my project folder is under C:/inetpu/wwwroot). When i try to access the application its giving an error occured Application Error. Any ideas????? This application worked fine on Apache.

    Here is my .htaccess content when I implemented it on Apache.

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

    Please guide me in configuring this.

  13. Maggi says:

    Finally configured ZendFramework on IIS. Thanks

  14. Maggi says:

    One thing i dont understand is that even if I dont Remove isapirewrite4.dll from ISAPI filter the application is working fine. I dont know why. Even i removed isaprewrite4.ini from inetsrv folder. Any ideas?

  15. lysender says:


    I really have no idea what’s going on with your setup Maggi. Maybe another IsapiRewrite4.dll still exists somewhere else. This is the thing I really hate when developing for Windows platform (MS platform). Things are so tricky that you spend so many hours trying to trace the problem.

    Good thing you solved it.

  16. swetha says:

    Can you tell me the reqrite rule to redirect to public/index.php

    i.e if i give the url http://localhost/app1 it should go to http://localhost/app1/public/index.php

  17. lysender says:

    Hi swetha

    If you are using Apache and you just wanted to redirect (not rewrite) you could try this:

    #Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

  18. swetha says:

    Hi Lysender

    I am using IIS server and I downloaded the file isaprewrite4.dll which you have provided and placed it under inetsrv folder. Where do I write the rewrite the rewrite rules? In which file? where do I place that file? and also can you provide the Rewrite rules for zend framework.

    Thanks in advance.

  19. swetha says:

    Hi Lysender

    I have a zend framework project with name zendapp under c:inetpub/wwwroot

    I can access this project using http://localhost/zendapp/public/index.php

    when I configured the IIRF based on the steps above I have this problem like

    when I access http://localhost/zendapp/public it is pointing to index.php file which is under c:/inetpub/wwwroot

    Do I need to change the rewrite rules?

    Is there a way that I can apply the IIRF only to the project zendapp????

    Please guide me. Thanks in advance.

  20. lysender says:

    Hi swetha,

    Now I understand you are using IIS. Forget about the rewrite rule about apache (the one I posted on one of the comments. What you need to do instead is to point the document root to: c:/inetpub/wwwroot/zendapp/public, that way, the rewrite rule will work.

    However, that will make the zend app the only application available and will be accessible via http://localhost. If you don’t like it that way and proceed to the directory instead http://localhost/zendapp/public, you will need to change the rewrite rule.

    If the application is set at rule, the rewrite rule for IsapiRewrite4.ini is:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    #RewriteRule ^/(.*)$ /index.php?q=$1 [I,L]
    RewriteRule ^/(.*)$ /index.php [L,I,U]

    However, if you want it to be in sud directory, you need to change it to something like:


    I’m no expert in either IIS or IIRF so I cannot suggest more.

  21. spatan says:

    Please this isapi stuff not working for me.
    i have my application in this directory c:/inetpub/wwwroot\smsapp. althought we already have other applications running on the c:/inetpub/wwwroot/. now how do i apply the Home Dicretory settings to my folder in order not to affect other applications that are runing on the server

  22. Satheesh says:

    I’ve installed iis6 on windows 2003 and also php on the server. Plain php files are working fine. I tested with phpinfo.php to get the phpinfo. But when i tried to host the zend application the problem started.

    Here the application is redirecting using isapi_rewrite module to /home. But it is not going to home controller. I’m using Doctrine ORM. Is there any problem with this? I don’t think so. Moreover it is always considering “default” as the module, “index” as the controller and “index” as the action even though i’m passing any thing through the URL like http://localhost/home/index/index. But it is not even going to the Default Controller also. Can you please help me in this situation. I’m using ISAPI_Rewrite 3, that supports .htaccess. It is redirecting to my public_mvc/index.php file in the application, from there it stopped dispatching.

    Thanks in advance.

  23. lysender says:

    Sorry Satheesh, is that the ISAPI_Rewirte by Helicon tech? I don’t have any experience on that so I cannot comment. Try using Ionic’s ISAPI Rewrite Filter and see if it works. That what this post is about.

  24. Satheesh says:

    Hi lysender,
    Thanks for your quick response. I tried installing the way you have mentioned in this article (I’ve downloaded Ionic’s ISAP Rewrite Filter (IIRF)). Plain php file is running fine. Again I’m facing the same problem with zend application like, even i passed any thing in the URL giving the module=>“default”, controller=>“index” and action=>“index”. Not going inside of the controller. I’m trying to solve from past 3 days. Can you please guide me here.

  25. Satheesh says:

    I’m not sure this is right place to post this question. But I’m expecting something from you people.
    When I’m passing the URL like http://localhost/home/index/index in one of my zend application I’m getting the module=>default, controller=>index, action=>index. Whatever may be the URL i’m getting the same thing. I’m running the application on IIS6 in windows 2003 platform. If i’m overriding the module as ‘home’ in Zend_Controller_Request_Abstract=>getModuleName() method then my home page is coming fine. I’m unable to get where exactly it is overriding the value to ‘default’,’index’,’index’. Can any one help me?

    Thanks in advance

  26. Satheesh says:

    When I’m passing the URL like http://localhost/home/index/index in my application I’m getting the module=>default, controller=>index, action=>index. Whatever may be the URL i’m getting the same thing. I’m running the application on IIS6 in windows 2003 platform. If i’m overriding the module as ‘home’ in Zend_Controller_Request_Abstract=>getModuleName() method then my home page is coming fine. I’m unable to get where exactly it is overriding the value to ‘default’,’index’,’index’. Can any one help me?

    Thanks in advance

    Update on this problem:
    The problem is with $_SERVER[‘HTTP_X_REWRITE_URL’]. I’m getting the same URI into both $_SERVER[‘HTTP_X_REWRITE_URL’] and $_SERVER[‘REQUEST_URI’] like /public_mvc/index.php. I’m not overriding the value of $_SERVER[‘HTTP_X_REWRITE_URL’] anywhere in my code. My .htaccess code is like this.

    RewriteEngine on

    RewriteRule ^admin-mvc(.*)$ public_mvc/admin.php [L]

    RewriteCond %{SCRIPT_FILENAME} !-f

    RewriteCond %{SCRIPT_FILENAME} !-d

    RewriteRule ^(.*)$ public_mvc/index.php

    RewriteRule ^$ /home [r=301,nc]

    I’m using ISAPI Rewrite 3 for URL Rewriting.

  27. lysender says:

    Hi Satheesh,

    Did you try to install your application into the document root? It seems not. In my application (the one I’m talking about in the post), it has only one project and is hosted on the document root.

    Try to move the document root to your public dir as first attempt to troubleshoot. Make sure that your ISAPI filter works.

    You keep mentioning that you are using Isapi Rewrite 3 but this post is about IIRF which is IsapiRewrite4. My knowledge about this IIRF is too limited so I cannot really help you that much.

    Take some time, maybe you have just missed something. It happens from time to time. This IIS+ZF integration also took me days to complete so I know the feeling.

  28. Satheesh says:

    Hi lysender,
    I have uninstalled ISAPI Rewrite 3. I installed IIRF(IsapiRewrite4) as you mentioned above. I have given the document root as c:\myapplication\public_mvc. And I’ve to pass like http://localhost/index.php/home OR http://localhost/index.php/results. Now i was able to get the module, controller, action correctly and also able to see the home page and remaining pages. As I’ve mentioned the doc root as public_mvc, I placed all the scripts, styles and images folders inside of the public_mvc. Now every thing is working fine man. Thank you very much for your replies ,good support and encouragement. Even i delete the .htaccess file it is working fine. How is it possible?Here one small favour, how can i avoid passing index.php through the URL every time like http://localhost/index.php/home. Can you please guide me here?

  29. lysender says:


    It is because IIRF does not interpret .htaccess files. The rewrite rules are read on the IsapiRewrite4.ini file instead as written in this post.

    Regarding getting rid of index.php in the URL, have you tried accessing the URL without index.php? Does it work?

    In my guess, it should work but if not, I cannot help you anymore. As what I’ve remembered, we are already contented to have that index.php in all our URLs as we are in the middle of quick migration.

    I think there is a forum for IIRF, just search around. But I really have the feeling that it is possible to get rid of index.php based on the previous comments from our fellow readers.

  30. Satheesh says:

    As I set the document root to c:\myapplication\public_mvc, there is no use of IsapiRewrite4.dll file. I can’t able to use the IsapiRewrite4.ini file also. I want to use .htaccess file, because in my application i’ve seperate layout for admin panel. By using .htaccess i can able to redirect to admin folder in the application. This can be done by the following code in .htaccess that works on apache server.

    RewriteEngine on
    RewriteRule ^admin-mvc(.*)$ public_mvc/admin.php [L]
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^(.*)$ public_mvc/index.php
    RewriteRule ^$ /home [r=301,nc]

    So I can pass URL like http://localhost/index.php/admin-mvc/home that can goes to admin.php file in public_mvc folder.

    Any idea on this?

Leave a Reply

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