1
我可以看到出站URL重写正在工作,因为它会用新URL替换页面上的所有URL。所以,在我把这个:IIS 7 URL重写模块
/post.asp?topic=question&id=123
它其重写为...
/question/123
但是,当我访问的URL重写我/question/123
得到一个404错误。它看起来像重写部分的工作,但如何加载URL一旦你重写了URL?
我用IIS中的“创建友好的URL”向导> URL重写,并检查出站和重定向规则为好,就像这个例子说明:http://learn.iis.net/page.aspx/497/user-friendly-url---rule-template/
下面是Web.Config中:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<remove name="RewriteUserFriendlyURL1" />
<remove name="RedirectUserFriendlyURL1" />
<rule name="RedirectUserFriendlyURL1" stopProcessing="true">
<match url="^post\.asp$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^topic=([^=&]+)&id=([^=&]+)$" />
</conditions>
<action type="Redirect" url="{C:1}/{C:2}" appendQueryString="true" redirectType="Permanent" />
</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="/post.asp?topic={R:1}&id={R:2}" />
</rule>
</rules>
<outboundRules>
<remove name="OutboundRewriteUserFriendlyURL1" />
<rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1">
<match filterByTags="A, Form, Img" pattern="^(.*/)/post\.asp\?topic=([^=&]+)&(?:amp;)?id=([^=&]+)&(?:amp;)$" />
<action type="Rewrite" value="{R:1}{R:2}/{R:3}/" />
</rule>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
你可以从web.config文件中发布你的重写路由配置吗? –
请参阅编辑。 –