2

我正在从 apache 迁移到 iis,并且遇到了 url 重写的问题。

我想要这样的所有请求:

http://192.168.0.44/aaa/bbb/ccc/testword

查询这个不友好的网址:

http://192.168.0.44/aaa/bbb/ccc/index.php?word=testword

所以我的 web.config 是:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
                    <match url="^192\.168\.0\.44/aaa/bbb/ccc/([^/]+)/?$" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="192.168.0.44/aaa/bbb/ccc/index.php?word={R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

但是当我访问这样的 url 时,我得到一个 404 not found 错误。细节:

Module  IIS Web Core
Notification    MapRequestHandler
Handler StaticFile
Error Code  0x80070002

Requested URL   http://192.168.0.44:80/aaa/bbb/ccc/testword
Physical Path   C:\inetpub\wwwroot\aaa\bbb\ccc\testword
Logon Method    Anonymous
Logon User  Anonymous

我究竟做错了什么 ?

ps那里会有一个域而不是那个IP,只是我想先在本地测试它,然后再进行直播。

安装了重写模块2。我可以在 iis manager gui 中看到。

提前致谢。

4

1 回答 1

1

我删除了这个位于顶层的重写规则,并以最简单的方式(没有长路径和 IP)在最深的文件夹( ccc )中实现它。它自动工作。

于 2013-02-18T17:24:54.913 回答