【问题标题】:URLRewriter works on localhost but not on the serverURLRewriter 适用于 localhost 但不适用于服务器
【发布时间】:2012-01-01 03:01:26
【问题描述】:

我在 localhost (ASP.NET 4) 上使用了这些角色,它可以工作:

  <rewriter>
    <rewrite url="~/man/(.+)" to="~/man/$1" processing="stop" />
    <rewrite url="~/man/^(/.+(\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js|\.axd)(\?.+)?)$" to="~/man/$1" processing="stop" />
    <rewrite url="~/files/^(/.+(\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js|\.axd|\.pdf|\.doc|\.ppt)(\?.+)?)$" to="~/files/$1" processing="stop" />
    <rewrite url="~/man/" to="~/man/default.aspx" processing="stop"/>
    <rewrite url="~/style/(.+)" to="~/style/$1" processing="stop" />
    <rewrite url="~/images/(.+)" to="~/images/$1" processing="stop" />
    <rewrite url="^(/.+(\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js|\.axd)(\?.+)?)$" to="$1" processing="stop" />
    <rewrite url="~/register.aspx" to="~/register.aspx" processing="stop" />
    <rewrite url="~/(.+)" to="~/default.aspx?pn=$1" />
  </rewriter>

例如,http://localhost/myweb/foo 指的是http://localhost/myweb/default.aspx?pn=foo,但在网络服务器上http://myweb.xx/foo 表示'404 - File or directory not found.'

【问题讨论】:

    标签: asp.net iis-7 url-rewriting web-config


    【解决方案1】:

    哪个版本的IIS有Server,因为II6有不同的方式,II7有不同的方式。

    【讨论】:

      【解决方案2】:

      检查您在 Web.Config 的哪个部分配置了规则,因为 System.web 用于 VS 开发服务器(“Cassini”)和 IIS6,而 System.WebServer 用于 IIS7。

      你也可以看看here

      【讨论】:

      • 我在 localhost 上安装了 IIS7,在服务器上安装了 IIS 7.5
      • 您能否粘贴更多有关您的 web.Config 的信息,特别是 system.web 和 system.webserver 部分?另外,你有 runAllManagedModulesForAllRequests="true" 吗?
      • 是的,我有,我改变了表达式然后它工作了!改为: 如果你把它写成答案,我会把它标记为答案。
      猜你喜欢
      • 2020-09-03
      • 1970-01-01
      • 2016-04-02
      • 1970-01-01
      • 2014-04-19
      • 2019-09-09
      • 2015-07-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多