0
 <urlrewritingnet rewriteOnlyVirtualUrls="true" contextItemsPrefix="QueryString" defaultPage="default.aspx" defaultProvider="RegEx" xmlns="http://www.urlrewriting.net/schemas/config/2006/07">
    <rewrites>
      <add name="book" virtualUrl="^~/book/(.*?)/([0-9]+)$" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/book.aspx?title=$1&amp;id=$2" ignoreCase="true" processing="stop" />
      <add name="page" virtualUrl="^~/page/(.*?)/([0-9]+)$" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/page/default.aspx?title=$1&amp;id=$2" ignoreCase="true" processing="stop" />
      <add name="register" virtualUrl="^~/register/(.*?)$" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/register.aspx?title=$1" ignoreCase="true" processing="stop" />
      <add name="login" virtualUrl="^~/login$" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/login.aspx" ignoreCase="true" processing="stop" />
      <add name="download" virtualUrl="^~/download/(.*?)$" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/download.aspx?title=$1" ignoreCase="true" processing="stop" />
      <add name="forgotpass" virtualUrl="^~/passwordrecovery$" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/forgotPassword.aspx" ignoreCase="true" processing="stop" />
      <add name="newsarchive" virtualUrl="^~/news-archive$" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/newsarchive.aspx" ignoreCase="true" processing="stop" />
      <add name="newsarchivekeywords" virtualUrl="^~/news-archive/(.*?)$" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/newsarchive.aspx?title=$1" ignoreCase="true" processing="stop" />
      <add name="news" virtualUrl="^~/news/(.*?)/([0-9]+)$" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/news.aspx?title=$1&amp;id=$2" ignoreCase="true" processing="stop" />
      <add name="articlearchive" virtualUrl="^~/article-archive$" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/articlearchive.aspx" ignoreCase="true" processing="stop" />
      <add name="articlearchivekeywords" virtualUrl="^~/article-archive/(.*?)$" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/articlearchive.aspx?title=$1" ignoreCase="true" processing="stop" />
      <add name="article" virtualUrl="^~/article/(.*?)/([0-9]+)$" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/article.aspx?title=$1&amp;id=$2" ignoreCase="true" processing="stop" />
      <add name="search" virtualUrl="^~/search/(.*?)$" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/search.aspx?s=$1" ignoreCase="true" processing="stop" />
    </rewrites>
  </urlrewritingnet>

这是我的 web.config 代码。localhost(iis)中的一切都可以,但是当我发布到服务器时。我刚得到这个

404 - 找不到文件或目录。您要查找的资源可能已被删除、名称已更改或暂时不可用。

4

1 回答 1

0

只需尝试将其添加到您的 we.config 中,问题就解决了

      <system.web>
    <httpModules>
      <add name="UrlRewriteModule"
           type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" />
    </httpModules>
</system.web>
于 2016-07-02T06:52:42.310 回答