we.config and cakephp applications
Is there a way to use web.config to replace .htaccess for a cakephp app on iis?
current .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
UPDATE:
Used import in IIS6. It gives me this web.config, but site does not work. I get a white screen. Also tried this http://book.cakephp.org/revisions/view/19937/URL-Rewrites-on-IIS7-Windows-hosts, and it didnt work either.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProce开发者_开发知识库ssing="true">
<match url="^$" ignoreCase="false" />
<action type="Rewrite" url="webroot/" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<action type="Rewrite" url="webroot/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Install the Microsoft URL Rewrite module for IIS. It'll let you import your apache rewrite rules. You can find the module here:
http://www.iis.net/download/urlrewrite
I use it with CakePHP on IIS 7.0 and 7.5 and it works a treat.
EDIT
Can you try this configuration for me?
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Imported Rule 1-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="/webroot/index.php?url={R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
精彩评论