【问题标题】:Windows Azure rewrite rules for Zend FrameworkZend Framework 的 Windows Azure 重写规则
【发布时间】:2014-07-18 17:50:56
【问题描述】:

目前我的 apache 上有以下 htaccess:

SetEnv APPLICATION_ENV development

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

我的应用程序使用 Zend Framework 作为 MVC 框架,目前我的 htaccess 在我的公共文件夹中。

在 MS Azure 上,我在 IIS 中创建了一个网站,并在我的根目录中放置了一个 web.config 文件,其配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
          <rules>
                <clear />
                <rule name="TransferToPublic-StaticContent" patternSyntax="Wildcard" stopProcessing="true">
                    <match url="*" />
                    <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
                        <add input="{REQUEST_URI}" pattern="*images*" />
                        <add input="{REQUEST_URI}" pattern="*css*" />
                        <add input="{REQUEST_URI}" pattern="*js*" />
                        <add input="{REQUEST_URI}" pattern="*bootstrap*" />
                        <add input="{REQUEST_URI}" pattern="*upload*" />
                        <add input="{REQUEST_URI}" pattern="*theme*" />
                        <add input="{REQUEST_URI}" pattern="*img*" />
                    </conditions>
                    <action type="Rewrite" url="public/{R:0}" />
                </rule>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^.*$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="public/index.php" />
                </rule>
          </rules>
        </rewrite>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
            </files>
        </defaultDocument>
    </system.webServer> 
</configuration>

问题是现在我无法访问具有以下路径 /public/index 或 /public/test 的页面

我做错了什么?配置中是否缺少某些内容? IIS 上 Zend Framework 的推荐配置是什么?

提前感谢您的帮助!

【问题讨论】:

    标签: zend-framework iis azure frameworks rewrite


    【解决方案1】:

    我知道这个问题有点老了,但如果你没有解决你的问题,这里是关于如何在 IIS 上配置 Zend Framework 的答案。

    Zend Documentation for IIS

    但也许您的问题还在于设置文档根目录。您不应将重写指向“public/index.php”,而应仅指向“index.php”,然后设置正确的文档根目录。

    这是我为 Azure 网站回答的问题:Azure Websites 仍在等待 Azure 云服务的答案:Azure Cloud Services

    在您自己配置 IIS 时,Azure VM 应该是不言自明的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-27
      • 1970-01-01
      • 2013-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-19
      • 1970-01-01
      相关资源
      最近更新 更多