如何为Zend配置iis

时间:2013-10-17 18:38:37

标签: zend-framework iis web rewrite

我尝试配置IIS 7以运行zend而无需键入/public/index.php/。如果尝试使用此URL访问我的应用程序http://<> / dev / foundation / SampleZendApp /(这是我的appliaction所在的位置),我收到以下错误

Message: Invalid controller specified (dev)
Stack trace:

#0 C:\inetpub\wwwroot\Dev\foundation\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 C:\inetpub\wwwroot\Dev\foundation\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#2 C:\inetpub\wwwroot\Dev\foundation\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#3 C:\inetpub\wwwroot\Dev\foundation\SampleZendApp\public\index.php(27): Zend_Application->run()
#4 {main}  

Request Parameters:

array (
  'controller' => 'dev',
  'action' => 'foundation',
  'module' => 'default',

只有在我面前添加/public/index.php才有效。如何更改IIS以便我不再需要输入/public/index.php?

如果有任何身体可以帮助我,我会非常感激。

谢谢。

1 个答案:

答案 0 :(得分:0)

在iis上有点棘手。

打开你的“Bash”:-)并执行:

%windir%\system32\inetsrv\appcmd.exe set config ^ -section:system.webServer/defaultDocument /+"files.[value='index.php']" ^ /commit:apphost

未安装时,您必须为iis添加“重写”模块:

安装:http://www.iis.net/download/urlrewrite

最后一步:将web.config添加到webroot(.htaccess的对应部分)

    <?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="ZF Rewrite" stopProcessing="true">
          <match url="^.*$" />
          <conditions logicalGrouping="MatchAny">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" pattern="" ignoreCase="false" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" pattern="" ignoreCase="false" />
          </conditions>
          <action type="None" />
        </rule>
        <rule name="Imported Rule 2" stopProcessing="true">
          <match url="^.*$" />
          <action type="Rewrite" url="index.php" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>