<rewrite url="^/(.*)-(\d+)$" to="~/Article2.aspx?title=$1&amp;id=$2" /><rewrite url="^(.*)/(\w+)-(\d+)$" to="$1/Article.aspx?title=$2&amp;id=$3" />需要将文件夹下的文件重写成根目录下以参数为目录的文件夹形式
如:http://localhost/web/aa.aspx?id=1&title=sfdsfd   写成: http://localhost/sfdsfd-1/
需要怎么设置URL重写
以及以上URL设置是否正确
如果我想实现在 string = "aaaa";
里面加上" 该怎么写!
string ddd = "aaaa";
如 string str = document.write("+ddd+");
要在ddd两边加上 " 改怎么写

解决方案 »

  1.   

    我和LZ的逻辑,和语言表达能力有一定的差距,看不懂我捎带问一个问题如果想重写为www.***.com/123/这样的形式,必须要在IIS添加扩展名映射吗
    不添加映射可以吗
      

  2.   

    不需要啊
    我以前一直都是用ReWrite 的http.ini 这种伪静态组件,所以对这个不是很了解
      

  3.   

    再顶下
    请问各位怎样把伪静态设成 根目录下的文件夹形式,拜托各位了,解决马上送分!!!
    如:http://localhost/web/aa.aspx?id=1&title=sfdsfd 写成: http://localhost/sfdsfd-1/
    万分火急~!!!
      

  4.   

    <LookFor>~/news/([\w]+).html$ </LookFor> 
    <SendTo>~/Show.aspx?Title=$1 </SendTo> 
    数字d(\d{0,5})
      

  5.   

    啊???
    上面那种格式已经定下来了
    如同以下
      <rewrite url="^(.*)/(\w+)-(\d+)$" to="$1/Article.aspx?title=$2&amp;id=$3" />  <rewrite url="^(.*)/(\d+)-(.*)\.(aspx|htm)$" to="$1/Article.aspx?title=$2&amp;id=$3" />
    只是我不知道怎么设置成根目录下的文件夹 不需要写成.HTM 的
      

  6.   

    顶就给分,解决加分!!!
    大家快来哦
    利用Intelligencia.UrlRewriter.dll 做伪静态
    如果是虚拟到文件夹下,需要在IIS里加映射吗?如果需要,要怎么添加?
    规则怎样?
      

  7.   

    不需要对IIS进行任何操作只要在config文件里设置好了,指定了规则,那么你访问伪静态的时候会自动解析
      

  8.   

    如果你把aspx重命名为HTML,那么真正的HTML页面就改成HTM后缀就可以,否则真正的HTML页面无法访问
      

  9.   

    <configSections>
      <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
      </configSections>
      <RewriterConfig>
        <Rules>
          <!-- Rules for Blog Content Displayer -->
          <RewriterRule>
            <LookFor>~/(.[0-9]*)\.html</LookFor>
            <SendTo>~/ArticleDetail.aspx?MyID=$1</SendTo>
              </RewriterRule>
        </Rules>
      </RewriterConfig>            2:再添加这个    <httpHandlers>
          <add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
          <add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
        </httpHandlers>        至此,已成功一大半,上面两个都添加到Web.Config,添加到什么位置看来没必要讲了!        最后一步:在IIS中找到自己的虚拟目录网站,点属性,然后点配置,然后弹出应用程序配置对话框,选择添加,添加的可执行文件路径为c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll,扩展名为.html 
    自己做的伪静态 Web.Config 自己给的配置
    <?xml version="1.0" encoding="utf-8"?>
    <!-- 
        注意: 除了手动编辑此文件以外,您还可以使用 
        Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
         “网站”->“Asp.Net 配置”选项。
        设置和注释的完整列表在 
        machine.config.comments 中,该文件通常位于 
        \Windows\Microsoft.Net\Framework\v2.x\Config 中
    -->
    <configuration>
      <configSections>
        <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
      </configSections>   <appSettings>
        <add key="dns" value="data source =  ; initial catalog =  ; user id=  ; password =  ;" />
        <add key="dnsace" value="" />
        <add key="pagecount" value="20" />
        <add key="xm" value="changchun" />
        <add key="ps" value="www5feicn" />
      </appSettings>  <connectionStrings/>
     
        <system.web>
          <compilation defaultLanguage="c#" debug="true"/>
          <customErrors mode="RemoteOnly" />
          <authentication mode="Windows" />
          <authorization>
            <allow users="*" />
          </authorization>
          <trace
              enabled="false"
              requestLimit="10"
              pageOutput="false"
              traceMode="SortByTime"
        localOnly="true"
        />
          <sessionState
                  mode="InProc"
                  stateConnectionString="tcpip=127.0.0.1:42424"
                  sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
                  cookieless="false"
                  timeout="20"
        />
          <globalization
                  requestEncoding="gb2312"
                  responseEncoding="gb2312"
       />
          <!--/********通过 httpHandlers 映射 **************/-->
          <httpHandlers>
            <add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
          </httpHandlers>
          <!--/********通过 httpHandlers 映射 **************/-->
            <!-- 
                设置 compilation debug="true" 可将调试符号插入
                已编译的页面中。但由于这会 
                影响性能,因此只在开发过程中将此值 
                设置为 true。
            -->
            <!--
                通过 <authentication> 节可以配置 ASP.NET 用来 
                识别进入用户的
                安全身份验证模式。 
            -->
          
            <!--
                如果在执行请求的过程中出现未处理的错误,
                则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
                开发人员通过该节可以配置
                要显示的 html 错误页
                以代替错误堆栈跟踪。        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
                <error statusCode="403" redirect="NoAccess.htm" />
                <error statusCode="404" redirect="FileNotFound.htm" />
            </customErrors>
            -->     </system.web>
      <!--/********URL 重写规则定义  **************/-->
      <RewriterConfig>
        <Rules>
          <RewriterRule>
            <LookFor>~/(\d+)\.aspx</LookFor>
            <SendTo><![CDATA[~/look.aspx?id=$1]]></SendTo>
          </RewriterRule>
          <RewriterRule>
            <LookFor>~/class/(\d+)\.aspx</LookFor>
            <SendTo><![CDATA[~/class.aspx?id=$1]]></SendTo>
          </RewriterRule>
          <RewriterRule>
            <LookFor>~/class/(\d+)_(\d+)\.aspx</LookFor>
            <SendTo><![CDATA[~/class.aspx?id=$1&pg=$2]]></SendTo>
          </RewriterRule>
        </Rules>
      </RewriterConfig></configuration>
      

  10.   

    iis6:http://hi.baidu.com/loveruifen/blog/item/41217dfbe9267b6d024f5667.html
    iis7:http://hi.baidu.com/kent_edwin/blog/item/841aa20e23524be4aa64570d.html