【发布时间】:2018-02-27 05:52:33
【问题描述】:
我有一个如下所示的原始 URL:
https://example.com/?page=map&path=Video's
我在 IIS 管理器中创建了一个规则,将上面的内容重写为
http://h2609709.stratoserver.net/map/Video's/
这很好用。
然而,当原来的网址是这样的:
https://example.com/?page=map&path=Video's/birthday/2016
它被正确地重写为:
https://example.com/map/Video's/birthday/2016/
但是页面导致错误 404。如何让服务器将&path=Video's/birthday/2016 解释为 查询 值而不是远程文件夹路径?
问题是由查询字符串中的/ 字符引起的。
Web.config
<rule name="RedirectUserFriendlyURL1" stopProcessing="true">
<match url="^$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^page=([^=&]+)&path=([^=&]+)$" />
</conditions>
<action type="Redirect" url="{C:1}/{C:2}" 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="?page={R:1}&path={R:2}" />
</rule>
【问题讨论】:
标签: url iis web url-rewriting web-config