【发布时间】:2017-12-04 07:42:57
【问题描述】:
我一直在 Visual Studio 中处理一个 ASP.NET Web 应用程序项目。在该项目中,当用户输入主机名时,他们会收到 404 错误,但我希望他们在刚刚输入主机名时被重定向到 index.html。
我想知道这是怎么做到的。以下是我使用的代码,但它不起作用
<location path="">
<system.webServer>
<httpRedirect enabled="true" destination="../index.html" httpResponseStatus="Permanent" />
</system.webServer>
</location>
【问题讨论】:
-
是的,有可能。
-
你需要做什么分享你的代码
-
使用
.htaccess文件重定向所有404错误 -
我认为这可以通过 .htaccess 来完成。你的服务器怎么样?
-
您的 html 文件的名称是什么?您的服务器指定了一个默认文档,如果没有请求特定文件,它会返回该文档。我猜默认文档是 index.html 或 index.htm。如果您在 IIS 上,它是 default.html/default.htm。将您的 html 文件重命名为这些名称中的任何一个,您应该一切顺利。
标签: html visual-studio