站長 IIS7 的 web.config 配置

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" />
	<!--啓用Gzip壓縮-->
	<urlCompression doStaticCompression="true" doDynamicCompression="false" />
	<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>
			<rule name="Mobile Jump">
				<match url="^(.*)$" />
				<conditions logicalGrouping="MatchAll">
					<add input="{HTTP_USER_AGENT}" pattern="nokia|iphone|android|motorola|symbian|sony|ericsson|mot|samsung|htc|sgh|lg|sharp|sie-|philips|panasonic|alcatel|lenovo|ipod|blackberry|meizu|netfront|ucweb|windowsce|palm|operamini|operamobi|opera|openwave|nexusone|cldc|midp|wap|mobile" />
				</conditions>
				<!-- 輸入要跳轉的手機站點 -->
				<action type="Redirect" url="http://m.xxx.com/{R:1}" redirectType="Found" />
			</rule>
		</rules>
	</rewrite>
</system.webServer>
</configuration>

 

PC全站跳轉手機首頁的配置方法

<rule name="Mobile Jump">
	<match url="^(.*)$" />
	<conditions logicalGrouping="MatchAll">
		<add input="{HTTP_USER_AGENT}" pattern="nokia|iphone|android|motorola|symbian|sony|ericsson|mot|samsung|htc|sgh|lg|sharp|sie-|philips|panasonic|alcatel|lenovo|ipod|blackberry|meizu|netfront|ucweb|windowsce|palm|operamini|operamobi|opera|openwave|nexusone|cldc|midp|wap|mobile" />
	</conditions>
	<!-- 輸入要跳轉的手機站點 -->
	<action type="Redirect" url="http://m.xxx.com/" redirectType="Found" />
</rule>

 

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>

 

 

 

 

 

 

發佈了351 篇原創文章 · 獲贊 23 · 訪問量 16萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章