.htaccesscakephpweb-configcakephp-2.0cakephp-2.2

Htaccess and CakePHP 2 on windows IIS7


I was having problems trying to configure the mod rewrite over windows and II7: CakePHP 2.2.2 not working on Windows IIS7 but finally i could import the htaccess in order to create the web.config file for IIS7.

The thing is: Now that file has been created in cakephp folder and i can access to the main page BUT it has not been created inside app/ or app/webroot in which you can find 2 more .htaccess files.

Now, i can not access any other view than the main site, it shows a 404 page not found error and i am pretty sure that it is because it is not getting those .htaccess files on the web.config.

My cakephp web.config file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <rewrite>
        <rules>
            <rule name="Imported Rule 1" stopProcessing="true">
                <match url="^$" ignoreCase="false" />
                <action type="Rewrite" url="app/webroot/" />
            </rule>
            <rule name="Imported Rule 2" stopProcessing="true">
                <match url="(.*)" ignoreCase="false" />
                <action type="Rewrite" url="app/webroot/{R:1}" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>
</configuration>

Although the CakePHP documentation tells you to add a different code (which makes the views work but no styles are loaded. And the home page don't work.) http://book.cakephp.org/2.0/en/installation/advanced-installation.html#url-rewrites-on-iis7-windows-hosts

When trying to access a CSS file from the URL i get this message:

Missing Controller

Error: CssController could not be found.

Error: Create the class CssController below in file: app\Controller\CssController.php

<?php
class CssController extends AppController {

}

Any idea? Working with Cakephp over windows is driving me crazy...


Solution

  • Ok, finally i get it work using this web.config i found on this site: http://www2.palomar.edu/pages/sphillips/cakephp-with-iis-7-rewrite-rules-in-a-sub-folder/

    I just changed the /{Path_To_CakePHP_Directory}/ for /.