【问题标题】:IIS Rewrite rule does not work in test enviromentIIS 重写规则在测试环境中不起作用
【发布时间】:2018-01-26 20:03:12
【问题描述】:

我的笔记本电脑(Win 10 Pro)上有一个在 IIS 10 中运行的 PHP 网站。
本网站使用重写规则并且在本地工作。
url mylaptop:8181/login 很好地重写为 mylaptop:8181/index.php?url=login

我将此网站放在运行 IIS 8.5 (Win Server 2012 R2) 的测试服务器上。
我的重写规则不再起作用。它将 URL testserver:207/login 重写为 testserver:207//testserver:207/login。显然这里出了点问题。

这是我的 web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="RedirectUserFriendlyURL1" stopProcessing="true">
                    <match url="^index\.php$" />
                    <conditions>
                        <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                        <add input="{QUERY_STRING}" pattern="^url=([^=&amp;]+)$" />
                    </conditions>
                    <action type="Redirect" url="{C:1}" appendQueryString="false" />
                </rule>
                <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
                    <match url="^([^/]+)/?$" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php?url={R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

我希望有人能指出我正确的方向!

【问题讨论】:

    标签: php iis url-rewriting


    【解决方案1】:

    我自己找到了解决方案。事实是,它根本与 IIS 无关,只是我的配置文件中的一个错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-12
      • 1970-01-01
      • 2015-07-10
      • 2017-03-08
      • 2020-01-18
      相关资源
      最近更新 更多