【问题标题】:Phalcon, IIS, RewritePhalcon,IIS,重写
【发布时间】:2016-01-17 09:10:06
【问题描述】:

我目前正在运行 Windows Server 2012 R2,IIS 8.5 和 Phalcon 2.0.8 在 PHP 5.5 上运行。

我有一个重写规则(使用从 Phalcon 导入的基本 .htaccess 文件)并且重写工作正常。但是,我在重写模块中创建了一个名为 APPLICATION_ENV 的系统变量,并将其附加到重写,值为 staging。

如果我查看 /public 的主索引以外的任何页面,则该值有效 - 登台被正确拉入。但是,在索引上,它不应用该值。为什么?

编辑:这是我当前的 web.config 文件,其中包含所有内容。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" patternSyntax="ECMAScript" 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" />
                    <serverVariables>
                        <set name="APPLICATION_ENV" value="staging" />
                    </serverVariables>
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

【问题讨论】:

  • 你应该显示你的重写配置
  • 这是我当前的 web.config,其中包含所有内容。编辑:添加到原始帖子。

标签: php iis url-rewriting rewrite phalcon


【解决方案1】:

问题(如果我理解正确的话)

为什么我访问/public时没有设置APPLICATION_ENV

答案: 原因是你指定了一个例外:

            <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            </conditions>

这意味着如果存在与访问路径匹配的目录,则不会执行重写。在您的情况下,您访问 /public 这不是控制器的名称,而是实际目录的名称。因此,它的索引文件是直接提供的。恰好与重写目标相同的事实只是巧合。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-01
    • 1970-01-01
    • 2014-02-07
    • 2016-06-27
    • 2013-06-16
    相关资源
    最近更新 更多