[英]IIS redirect maps not working for root destination
当我将目标指向 root 时,我在让 rewrite pas 正常工作时遇到了一些麻烦。
如果我指向 /page/ 目的地 t 似乎可以正常工作,但如果我指向 / 则不会。 以下是我在 web.config 中的内容
<rewrite>
<rewriteMaps>
<rewriteMap name="StaticRewrites">
<add key="/1" value="/article.aspx?id=1&title=some-title" />
<add key="/random_page.htm" value="/" />
<add key="/friends.htm" value="index.php" />
<add key="/page_2.htm" value="/index.php" />
<add key="/some_other_page.htm" value="/some_other_page/" />
<add key="/some_page_test.htm" value="/test21.php" />
<add key="/2nd_page_test.htm" value="/test.txt" />
<add key="/3rd_page_test" value="/test1.htm" />
<add key="/4th_page_test.htm" value="article.aspx?id=1&title=some-title" />
<add key="/root_page_again.htm" value="/" />
</rewriteMap>
</rewriteMaps>
<rules>
<rule name="Rewrite rule1 for StaticRewrites">
<match url="(.*)" />
<conditions>
<add input="{StaticRewrites:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Rewrite" url="{C:1}" appendQueryString="false" />
</rule>
<rule name="WordPress: http://123.123.12.123" patternSyntax="Wildcard">
<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/{R:0}" />
</rule>
</rules>
</rewrite>
第一个作品
第二、第三、第四个不起作用
第 5、6、7、8 和 9 号确实有效
第 10 个或最后一个没有
我为 IIS 8.5 的隐私编辑了一些明显的地方
第一个有效,因为它匹配第一条规则。
第二个不起作用,因为您没有设置默认文档。 它匹配第一条规则,如果您设置默认文档,它将重写为 http://localhost:xx/ 并显示默认文档。
第三条和第四条匹配第一条规则,都改写为http://localhsot:xx/index.php
第 5、6、7、8 条都符合第 1 条和第 2 条规则,但重写为 http://localhsot:xx/index.php//”value” 并显示 index.php。
第 9 条匹配第 1 条规则并重写为 http://localhsot:xx/article.aspx?id=1&title=some-title。
第 10 次与第 2 次相同。
您可以打开失败请求跟踪,它会记录整个重写过程,包括是否符合规则以及是否重写。
我很抱歉我没有发布配置文件的开头。 我假设每个人都会理解默认文档已被设置,因为没有它整个站点将无法加载。
这是我之前没有发布的 web.config 的开始部分
<configuration>
<system.webServer>
<defaultDocument>
<files>
<add value="index.php" />
</files>
</defaultDocument>
<rewrite>
<rewriteMap name="StaticRewrites">
我感谢在这件事上的任何帮助,并且知道我必须遗漏一些简单的东西,因为大多数规则实际上都有效
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.