原页:http://aaa.com/song/default?id=12345&url=http://********
URL重写:http://aaa.com/song/song12345
<LookFor>*****</LookFor>
<SendTo>******</SendTo>
请问如何才能实现呢

解决方案 »

  1.   


    <RewriterConfig>
       <Rules>
       <RewriterRule>
          <LookFor>要查找的模式</LookFor>
          <SendTo>要用来替换模式的字符串</SendTo>
       </RewriterRule>
       <RewriterRule>
          <LookFor>要查找的模式</LookFor>
          <SendTo>要用来替换模式的字符串</SendTo>
       </RewriterRule>
       ...
       </Rules>
    </RewriterConfig>
      

  2.   

    <RewriterRule>
    <LookFor>~/(\d+)\.html</LookFor>
    <SendTo>~/NewsView.aspx?NewsID=$1</SendTo>
    </RewriterRule>
      

  3.   

    <LookFor><![CDATA[~/song/song(\d).html]]></LookFor>
    <SendTo><![CDATA[~/song/default?id=$1]]></SendTo>
    别忘了更改要连接的地方按照song/song(\d).html的格式更改就可以了
      

  4.   

    大家的回答是可以的,但最主要的是我的有两个参数,该怎么办啊
    http://aaa.com/song/default?id=12345&url=http://********
      

  5.   

    首先你要对url这个参数进行UrlEncode一下,<LookFor><![CDATA[~/song/song(\d)-([0-9a-zA-Z\%\.-])\.html]]></LookFor>
    <SendTo><![CDATA[~/song/default?id=$1&url=$2]]></SendTo>
      

  6.   

    改一下,
    <LookFor><![CDATA[~/song/song(\d)-([0-9a-zA-Z\%\.-]{1,})\.html]]></LookFor>
    <SendTo><![CDATA[~/song/default?id=$1&url=$2]]></SendTo>
      

  7.   

    我这样写的
    <LookFor>~/song/song(\d+)-((http|HTTP)://([\w-]+\.)*[\w-]+(:\d+)?(/[\u4e00-\u9fa5\w- ./?%&amp;=]*)?$)\.html</LookFor>
    <SendTo>~/song/default.aspx?mid=$1&amp;murl=$2</SendTo>地址栏是:http://localhost:3742/song/song298566&http://25a.520135.com:81/mp3/356.wma.html
    第二个参数是一个音乐地址.错误:
    鈥?cuangs鈥濆簲鐢ㄧ▼搴忎腑鐨勬湇鍔″櫒閿欒銆?hr width=100% size=1 color=silver>
    HTTP 閿欒 400 - Bad Request銆?/i> 
      

  8.   

    http://localhost:3742/song/song298566http://25a.520135.com:81/mp3/356.wma.html
    红色部分是-而不是&