我试图重写 azure 中 blob 中的 url 以返回静态 html,但它总是显示以下 404.4 错误:
The file extension for the requested URL does not have a handler configured to process the request on the Web server.
- 模块: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,但仍然显示相同的错误。另外,如果我将重写更改为重定向,它会起作用,但这会更改我不想要的网址。
提前致谢。
最佳答案
我今天刚刚遇到了同样的问题,事实证明,这是因为 URL 重写仅在您显然在同一网站/网络应用程序内重定向时才有效。请参阅http://blogs.msdn.com/b/asiatech/archive/2011/08/25/return-404-4-not-found-when-url-rewrite.aspx寻求解决方案。提示:您需要安装 ARR 并在 ARR -> 服务器代理设置下选中“启用代理”框
希望对您有帮助。如果为时已晚,从互联网上遇到该问题的人数来看,我相信这会对其他人有所帮助
关于ASP.net URL 重写到不同的域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30865164/