CakePHP with IIS 7 Rewrite Rules in a Sub Folder

My co-worker pointed me to a new PHP Database MVC resource called CakePHP but I couldn’t get the URL Rewrite rules to work on IIS 7. After much trouble shooting I finally tweaked the web.config file to work with CakePHP installed in a sub folder.

Here is the web.config file I used with CakePHP in a sub folder.

 <configuration>
   <system.webServer>
     <rewrite>
       <rules>
         <clear/>
         <rule name="Imported Rule 0" stopProcessing="true">
           <match url="^(img|css|files|js)(.*)$"></match>
           <action type="Rewrite" url="/{Path_To_CakePHP_Directory}/app/webroot/{R:1}{R:2}" appendQueryString="false"></action>
         </rule>
         <rule name="Imported Rule 1" stopProcessing="true">
           <match url="^(.*)$" ignoreCase="false" />
           <conditions logicalGrouping="MatchAll">
             <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
             <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
           </conditions>
           <action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" />
         </rule>
         <rule name="Imported Rule 2" stopProcessing="true">
           <match url="^$" ignoreCase="false" />
           <action type="Rewrite" url="/{Path_To_CakePHP_Directory}/app/webroot/" />
         </rule>
         <rule name="Imported Rule 3" stopProcessing="true">
           <match url="(.*)" ignoreCase="false" />
           <action type="Rewrite" url="/{Path_To_CakePHP_Directory}/app/webroot/{R:1}" />
         </rule>
         <rule name="Imported Rule 4" stopProcessing="true">
           <match url="^(.*)$" ignoreCase="false" />
           <conditions logicalGrouping="MatchAll">
             <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
             <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
           </conditions>
           <action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" />
         </rule>
       </rules>
     </rewrite>
   </system.webServer>
 </configuration>

Blog Publishing Programs

Since I am starting to post on this site now I thought I would give mention to some of the tools I use for creating posts. The first tool I am going to talk about is Windows Live Writer.

I published this post using Windows Live Writer 2011 on my Windows 7 computer. It has a lot of nice options for a free software program. It is very easy to setup with WordPress based blogs and gives you a lot of basic word processing type options such as spell-check, font selection and other tools. The interface uses the new Ribbon that was introduced in Word 2007.

The program is extendable via plugins for adding more functionality. It also has built-in options for inserting pictures and videos from multiple sources. You also have a quick preview option to see your post before actually publishing it.

If your running a Windows operating system I would recommend giving it try to see if it makes publishing to WordPress a lot easier.