Ad

UrlRewriting Does Not Work On Server, But On Localhost It Works Fine On Asp.net?

 <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>

here is my web.config codes. evry thing is ok in localhost(iis) but when i published to server. i just got this

404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

Ad

Answer

just try to add this to your we.config and the problem has been solved

      <system.web>
    <httpModules>
      <add name="UrlRewriteModule"
           type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" />
    </httpModules>
</system.web>
Ad
source: stackoverflow.com
Ad