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文件中發佈你的重寫路由配置嗎? –
請參閱編輯。 –