【问题标题】:ASP.net URL rewrite to a different domainASP.net URL 重写到不同的域
【发布时间】:2015-09-01 03:05:44
【问题描述】:

我正在尝试在 azure 中重写为 blob 中的 url 以返回静态 html,但它总是指出以下 404.4 错误:

请求的 URL 的文件扩展名没有处理程序 配置为在 Web 服务器上处理请求。

  • 模块:IIS Web 核心
  • 通知:MapRequestHandler
  • 处理程序:静态文件
  • 错误代码:0x8007007b

这是我的 web.config 文件:

  <system.web>
    <authentication mode="None" />
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <httpHandlers>
      <add path="*.html" verb="*" type="System.Web.StaticFileHandler" />
    </httpHandlers>
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <validation validateIntegratedModeConfiguration="false" />

    <staticContent>
      <remove fileExtension=".css" />
      <mimeMap fileExtension=".css" mimeType="text/css; charset=UTF-8" />
      <remove fileExtension=".js" />
      <mimeMap fileExtension=".js" mimeType="text/javascript; charset=UTF-8" />
      <remove fileExtension=".json" />
      <mimeMap fileExtension=".json" mimeType="application/json; charset=UTF-8" />
      <remove fileExtension=".rss" />
      <mimeMap fileExtension=".rss" mimeType="application/rss+xml; charset=UTF-8" />
      <remove fileExtension=".html" />
      <mimeMap fileExtension=".html" mimeType="text/html; charset=UTF-8" />
      <remove fileExtension=".xml" />
      <mimeMap fileExtension=".xml" mimeType="application/xml; charset=UTF-8" />
    </staticContent>

    <rewrite>
      <rules>
        <rule name="static" stopProcessing="true">
          <match url="static/(.*)" />
          <action type="Rewrite" url="https://www.blobtest.blob.core.windows.net/static/{R:1}" />
        </rule>
      </rules>
    </rewrite>

  </system.webServer> 

我添加了一个 httphandler 和 mimemaps,但仍然显示相同的错误。此外,如果我将 Rewrite 更改为 Redirect 它可以工作,但这会更改我不想要的 url。

提前致谢。

【问题讨论】:

    标签: asp.net azure url-rewriting


    【解决方案1】:

    我今天刚刚遇到了同样的问题,事实证明这是因为 URL 重写只有在您显然在同一个站点/网络应用程序中重定向时才有效。有关解决方案,请参阅 http://blogs.msdn.com/b/asiatech/archive/2011/08/25/return-404-4-not-found-when-url-rewrite.aspx。提示:您需要安装 ARR 并在 ARR -> 服务器代理设置下选中“启用代理”框

    希望对您有所帮助。如果为时已晚,从互联网上遇到该问题的人数来看,我相信它会帮助其他人

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-17
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      • 2014-04-06
      • 2012-02-23
      • 2012-01-03
      • 1970-01-01
      相关资源
      最近更新 更多