我在 web.config 里定义了404错误页的跳转指向地址栏里输入“http://www.xxxx.com/xxx.aspx”能正常跳转
可如果地址栏输入的是以下的,就不能正常跳转了某个目录:“http://www.xxxx.com/xxx/”
不同的后缀名:“http://www.xxxx.com/xxx.html”或“http://www.xxxx.com/xxx.htm”或“http://www.xxxx.com/xxx.php”等
请问这个怎么解决?
可如果地址栏输入的是以下的,就不能正常跳转了某个目录:“http://www.xxxx.com/xxx/”
不同的后缀名:“http://www.xxxx.com/xxx.html”或“http://www.xxxx.com/xxx.htm”或“http://www.xxxx.com/xxx.php”等
请问这个怎么解决?
二、Apache下设置404错误页面
为Apache Server设置 404错误页面的方法很简单,只需在.htaccess 文件中加入如下内容即可:ErrorDocument 404 /notfound.php注意:
1.切记不要将404错误转向到网站主页,否则可能会导致主页在搜索引擎中消失
2.切记不要使用绝对URL( SEOpeixun/">http://www.seo-peixun.com/SEOpeixun/ 形式),如果使用绝对URL返回的状态码是“302”+“200”(已测试)三、IIS/ASP.net下设置404错误页面首先,修改应用程序根目录的设置,打开 “web.config” 文件编辑,在其中加入如下内容:以下为引用的内容:
<configuration>
<system.web>
<customErrors mode=”On” defaultRedirect=”error.asp”>
<error statusCode=”404″ redirect=”notfound.asp” />
</customErrors>
</system.web>
</configuration>
注:上文例中“error.asp”为系统默认的404页面,“notfound.asp”为自定义的404页面,使用时请修改相应文件名。
然后,在自定义的404页面“notfound.asp”中加入:以下为引用的内容:
<%
Response.Status = “404 Not Found”
%>
这样,便可以保证IIS能够正确地返回“404”状态码
和iis
IIS - > 选择站点 -> 属性 -> 选择 文档 选项卡 -> 勾选 启用默认文档。 将默认页移到第一位。配置错误页:<system.web><!--定义友好的错误,出错默认导向到 ErrorPage.html -->
<customErrors mode="RemoteOnly" defaultRedirect="ErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors></system.web>
<configuration>
<system.web>
<customErrors mode=”On” defaultRedirect=”error.asp”>
<error statusCode=”404″ redirect=”notfound.asp” />
</customErrors>
</system.web>
</configuration>就这个可以,我做项目也是这样设置的。
和iis
IIS - > 选择站点 -> 属性 -> 选择 文档 选项卡 -> 勾选 启用默认文档。 将默认页移到第一位。
<system.web>
<customErrors mode=”On” defaultRedirect=”error.asp”>
<error statusCode=”404″ redirect=”notfound.asp” />
</customErrors>
</system.web>
</configuration> 注:上文例中“error.asp”为系统默认的404页面,“notfound.asp”为自定义的404页面,使用时请修改相应文件名。 然后,在自定义的404页面“notfound.asp”中加入: <%
Response.Status = “404 Not Found”
%> 这样,便可以保证IIS能够正确地返回“404”状态码。 注:为显示方便,上文代码中使用的是全角的“<”与“>”,应用时应将其改为半角字符。 在IIS/ASP.net下设置404静态页面 设置静态404错误页面的方法则比较简单,在IIS管理器中右键单击要管理的网站,打开“属性”中的“自定义错误信息”页,为“404”设定相应的错误信息页即可。不过,此处在“消息类型”中一定要选择“文件”或“默认值”,而不要选择“URL”,不然,将导致返回“200”状态码。
和iis
IIS - > 选择站点 -> 属性 -> 选择 文档 选项卡 -> 勾选 启用默认文档。 将默认页移到第一位。配置错误页:<system.web><!--定义友好的错误,出错默认导向到 ErrorPage.html -->
<customErrors mode="RemoteOnly" defaultRedirect="ErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors></system.web>