UrlRewriter URL重写

曾祥展

default.aspx.cs:

protected void Button1_Click(object sender, EventArgs e)
   {
       Response.Redirect("product/item=33");
   }
   protected void Button2_Click(object sender, EventArgs e)
   {
       Response.Redirect("Registration");
   }

 

曾祥展

点击商品 URL:http://localhost:3052/WebSite1/product/item=33

点击注册 URL:http://localhost:3052/WebSite1/Registration

 

 

<configuration> 
  <configSections> 
    <section name="urlrewritingnet"   
             restartOnExternalChanges="true" 
             requirePermission ="false"  
             type="UrlRewritingNet.Configuration.UrlRewriteSection, 
                   UrlRewritingNet.UrlRewriter"  /> 
  </configSections> 
</configuration> 

 

 

 

 <system.web> 
    <httpModules> 
     <add name="UrlRewriteModule" 
         type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" /> 
    </httpModules>     
  </system.web> 

 

 

 

<urlrewritingnet rewriteOnlyVirtualUrls="true" contextItemsPrefix="QueryString" defaultPage="default.aspx" defaultProvider="RegEx" xmlns="http://www.urlrewriting.net/schemas/config/2006/07">
      <rewrites>
          <add name="RewriteOnDomain" virtualUrl="^http\://(.*)/product/item=(.*)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/ProductDetails.aspx?productCode=$2" rewrite="Domain" ignoreCase="true"/>
          <add name="Rewrite" virtualUrl="^http\://(.*)/Registration" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/Registion.aspx" rewrite="Domain" ignoreCase="true"/>
      </rewrites>
  </urlrewritingnet>
posted @ 2010-01-07 11:49  曾祥展  阅读(792)  评论(0编辑  收藏  举报