1

我有一个 index.html 文件和一个 default.asp 文件(同一目录)

并且我只想在输入域/服务器名称时访问 index.html 文件,例如 www.cat.com 如果输入了其他任何内容我想显示 Response.Write('Page Not Found')

我的 default.asp 文件:

<% 

 If InStr( UCase(Request.ServerVariables("SERVER_NAME")),  UCase("cat.com") ) = 0 Then 
    Response.Write("Page Not Found") 
 End If 
%> 

我这样做的原因是因为我将多个域指向同一个目录。

目前,这两个域都被重定向到 index.html 文件。

如果输入了 cat.com 以外的内容,是否可以停止执行?

谢谢

4

1 回答 1

4

要在代码中调用 404 样式行为,请使用

Response.Status = "404 Not Found"
Response.End

但是,您不能根据请求中的主机名阻止对 .html 文件等静态内容的访问。

于 2012-07-24T07:53:52.973 回答