我正在从 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 中看到。
提前致谢。