Thursday, February 19, 2009

CakePHP on IIS / ISAPI with mod_rewrite support

If you have ever taken on the challenge of installing CakePHP on IIS you would know this is no walk in the park. The amount of information on the subject is really small and spread out all over the net. I hope to give you a straight forward guide to get you up and going.

Aparche is really the best way to go when using CakePHP. But if you simply have to use IIS then continue reading. Also, It goes without saying I take no responsibility for any problems you might run into by following this guide. The information is provided as is for informational purposes only.

Lets get down to business

I'll be showing you how to do this using the
free / lite version of the program to get CakePHP up and running presuming that you have ISS and PHP configured and running correctly (make sure that PHP is using ISAPI not CGI).


"ISAPI_Rewrite Lite is completely free and it is a good solution for development or testing purposes and for small servers that host only a few web sites and don’t require distributed configurations or proxy functions."

If your willing to pay you can get the premium version of "ISAPI_Rewrite" which, according to helicontech, should provide support for CakePHP's .htaccess files.

You can download the lite version and full version here:

Configuring ISS

Configure ISS to not check the existance of scripts in PHP.

From http://http//

1) Go to your server admin panel, right-click on the web server (ex: Default Web Site) and click on properties.

Go to the Home Directory tab at the top and click on the Configuration button near the bottom of that page.

3) Find the .php extension listed in the “Application Configuration” page that appears; click on the .php extension and then click the edit button near the bottom of the page.

4) You should be on the “Add/Edit Application Extension Mapping” page: simply uncheck the “Check that file exists” box at the bottom of the page.

5) Click OK, Click OK again, Click OK once more (you should’ve closed all the windows).

6) Now restart IIS (command prompt -> IISReset).

- Double check your security permissions for the Cake folders/files you dropped into your web root. Just remember that something unzipped to the desktop and copied into your Inetpub directory will often have security permissions that will prevent the server from accessing some files properly.

- Remember that the app/temp folder must be writeable by the web server (for caching). That particular problem had me scratching my head once or twice.

Also make sure that index.php is set to load automatically as first preferrence.

Installing CakePHP & setting permissions

Get a copy of CakePHP from and extract it into your site. Set the webroot (cake\app\webroot) folder inside the cake as the default web directory (not wwwroot) from the properties box in your website in the ISS Management page.

Make sure that your cake\app\tmp folder has write permissions set.

Installing and Configuring ISAPI_Rewrite 3 Lite

Because the lite version of ISAPI_Rewrite doesn't allow for multiple varying .htaccess files a general configuration must be set.

Download ISAPI_Rewrite 3 Lite from:

-Run the installer
-access the "ISAPI_Rewrite Manager" from the start menu and click edit
-paste in this:

# Helicon ISAPI_Rewrite configuraion file
# Version

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]

-click apply in the window and then apply again.

And Finally...
Test to see if your hard work has payed off.
Point your browser to the homepage of your website ie.

everything should be working as in apache!

feel free to leave a comment about any improvements or questions you may have

Note: if you get "Permission denied in ...\cake\libs\file.php on line 292" or "cake [function.unlink]: permission denied in file.php" it means your tmp file has not been given write permissions. Make sure this is set.



  1. Thank you for this guide, after following this step by step down to the letter I am getting a series of errors in this format = Warning: unlink(C:\cakeproject\app\tmp\cache\persistent\cake_core_core_paths) [function.unlink]: Permission denied in C:\cakeproject\cake\libs\file.php on line 292

    mostly all function.unlink permission denied errors.

  2. You have to make sure that your tmp folder in the "app" folder is writable as well as readable. I've now added this to the blog.

  3. This does nog work for me :( I used the latest cake ( I can get things to work on IIS, but only without nice url's As soon as I'm trying to use ISAPI_Rewrite (i bought that last year), I'm receiving errors like:

    Error: Url=Controller could not be found.

    Also the css files do not get found.

  4. Make sure that "cake\app\webroot" is your server's webroot folder. Are you using ISAPI_Rewrite 3? becuase the premium version should have in-built support for .htaccess files. Otherwise try ISAPI_Rewrite 3 with the above method.