当前位置: 代码迷 >> ASP.NET >> web.config伪静态里有个正则不会写!该怎么解决
  详细解决方案

web.config伪静态里有个正则不会写!该怎么解决

热度:6279   发布时间:2013-02-25 00:00:00.0
web.config伪静态里有个正则不会写!
比如:www.xxx.com/user/?username=csdn
伪静态之后就是:www.xxx.com/csdn

使用了这个规则之后。发现:www.xxx.com 无法打开了,只能输入:www.xxx.com/index打开。

包括
www.xxx.com/login
www.xxx.com/reg
www.xxx.com/help

登录页,注册页。等等二级页面都无法打开。
请问下,正则里怎没排除 index 、login 、reg 、help ,等!让这些页面可以打开。

代码如下:

  <configSections>
    <section name="CustomConfiguration" type="URLRewriter.Config.UrlsSection, URLRewriter"/>
  </configSections>
  <CustomConfiguration>
    <urls>
      <add virtualUrl="~/index" destinationUrl="~/default.aspx"/>      
      <add virtualUrl="~/([\w]+)*" destinationUrl="~/user/?username=$1"/>
    </urls>
  </CustomConfiguration>
正则

------解决方案--------------------------------------------------------
~/((?!index
------解决方案--------------------------------------------------------
login
------解决方案--------------------------------------------------------
reg
------解决方案--------------------------------------------------------
help)\w+)

~/user?username=$1
  相关解决方案