当前位置:编程学习 > C#/ASP.NET >>

URLRewriter重写问题

http://www.abc.com/index.aspx?id=1  重写为  http://www.abc.com/1/

http://www.abc.com/index.htm  重写为  http://www.abc.com/index/

以上2个如何重写? --------------------编程问答-------------------- 除 --------------------编程问答-------------------- ~/index/?
~/index.htm


~/(\d+)/?
~/index.aspx?id=$1


--------------------编程问答-------------------- ~/index/?
~/index.htm

静态重写静态这样可以吗? --------------------编程问答-------------------- <script type="text/javascript">
   alert("你好");
</scirpt> --------------------编程问答-------------------- 也想知道!!!  帮顶!!! 请问重写是不是配置到web.config里面? --------------------编程问答-------------------- ................ 这个貌似很简单 web.config 配置就行了 2L的方法是正确滴 --------------------编程问答--------------------
<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler,
 URLRewriter" />
  </configSections>
    <RewriterConfig>
        <Rules>
            <RewriterRule>
                <LookFor>~/ListCategories\.aspx</LookFor>
                <SendTo>~/Default.aspx</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/(\d+)\.html</LookFor>
                <SendTo>~/Cover.aspx?id=$1</SendTo>
            </RewriterRule>
        </Rules>
    </RewriterConfig>
    <system.web>
        <httpModules>
            <add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter"/>
        </httpModules>
        <compilation debug="true"/>
</system.web>
</configuration>
--------------------编程问答--------------------
<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler,
 URLRewriter" />
  </configSections>
    <RewriterConfig>
        <Rules>
            <RewriterRule>
                <LookFor>~/ListCategories\.aspx</LookFor>
                <SendTo>~/Default.aspx</SendTo>
            </RewriterRule>
            <RewriterRule>
                <LookFor>~/(\d+)\.html</LookFor>
                <SendTo>~/Cover.aspx?id=$1</SendTo>
            </RewriterRule>
        </Rules>
    </RewriterConfig>
    <system.web>
        <httpModules>
            <add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter"/>
        </httpModules>
        <compilation debug="true"/>
</system.web>
</configuration>
--------------------编程问答-------------------- 算了,没XML格式的 --------------------编程问答--------------------
引用 9 楼 qiujialongjjj 的回复:
算了,没XML格式的


http://www.abc.com/index.aspx?id=1  重写为  http://www.abc.com/1/

http://www.abc.com/index.htm  重写为  http://www.abc.com/index/

看第二个 是 静态 的   .htm --------------------编程问答--------------------

 <RewriterRule>            
 <LookFor>http://(\w+).(\w+).(\w+)/(\w+)/</LookFor>
 <SendTo>~/index.aspx?id=$4</SendTo>         
 </RewriterRule>  
 
    
  
 <RewriterRule>               
 <LookFor>http://(\w+).(\w+).(\w+)/(\w+)/</LookFor>                
 <SendTo>~/$4.htm</SendTo>           
 </RewriterRule>
 
  --------------------编程问答-------------------- 8楼、9楼都说得很清楚了,楼主,你再把URLRewriter.dll引用到项目中就可以lookfor和sendto了
--------------------编程问答-------------------- http://www.abc.com/index.aspx?id=1  重写为  http://www.abc.com/1/  动态页面

http://www.abc.com/index.htm  重写为  http://www.abc.com/index/  静态页面

以上2个如何重写?  --------------------编程问答-------------------- 百度一下 你就知道。。。    http://www.cnblogs.com/notus/archive/2009/03/26/1422548.html --------------------编程问答-------------------- 你们的这些重写我都知道的,但是我要一下的重写效果

http://www.abc.com/index.aspx?id=1  重写为  http://www.abc.com/1/

http://www.abc.com/index.htm  重写为  http://www.abc.com/index/

以上2个如何重写? 
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,