站长 IIS7配置404与301

PC站点配置 web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
	<httpErrors>
		<remove statusCode="404" subStatusCode="-1" />
		<!--统一修改为404.asp,因为这样返回状态码才会是404-->
		<error statusCode="404" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" />
	</httpErrors>
</system.webServer>
<system.webServer>
	<!-- http://www.xxx.com 替换为对应的网站,带www-->
	<httpRedirect enabled="false" destination="http://www.xxx.com" exactDestination="false" childOnly="false" httpResponseStatus="Permanent" />
	<urlCompression doStaticCompression="true" doDynamicCompression="true" />
	<defaultDocument>
		<files>
			<clear />
			<add value="index.html" />
			<add value="index.php" />
			<add value="index.htm" />
			<add value="index.asp" />
		</files>
	</defaultDocument>
</system.webServer>
<system.webServer>
	<rewrite>
		<rules>
			<rule name="WWW Redirect" stopProcessing="true">
				<match url=".*" />
				<conditions>
					<!--xxx.com,替换为对应的网站,不带www-->
					<add input="{HTTP_HOST}" pattern="^xxx.com$" />
				</conditions>
				<!-- http://www.xxx.com 替换为对应的网站,带www-->
				<action type="Redirect" url="http://www.xxx.com/{R:0}" redirectType="Permanent" />
			</rule>
		</rules>
	</rewrite>
</system.webServer>
</configuration>

 

手机站点配置 web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <urlCompression doStaticCompression="true" doDynamicCompression="true" />
        <httpErrors>
            <remove statusCode="404" subStatusCode="-1" />
			<!--统一修改为404.asp,因为这样返回状态码才会是404-->
            <error statusCode="404" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" />
        </httpErrors>
    </system.webServer>
</configuration>

 

404.asp

<!doctype html>
<html>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Session.codePage=65001%>
<% Response.Charset = "utf-8" %>
<% Response.Status = "404 Not Found" %>
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="10; URL=/" />
<title>网页或文件未找到</title>
</head>
<body>
<script type="text/javascript" src="http://www.qq.com/404/search_children.js" charset="utf-8" homePageUrl="/" homePageName="返回首页"></script>
</body>
</html>

 

进入 http://tool.chinaz.com/pagestatus/

效果图:

 
 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值