欧美日韩精品在线,国内精品久久久久久久久,一级毛片恃级毛片直播,清纯唯美亚洲综合欧美色

ISAPI Rewrite實現(xiàn)IIS 301轉(zhuǎn)向_負載集群教程

編輯Tag賺U幣

Windows主機IIS下的301轉(zhuǎn)向設(shè)置

在IIS 管理后臺 -> 選擇你要重定向的文件或文件夾 -> 右鍵“重定向到URL” -> 輸入需要轉(zhuǎn)向的目標URL ->選擇“資源的永久重定向”。

另外,如果你的Windows虛擬主機空間支持ISAPI_Rewrite,那么在IIS下利用ISAPI_Rewrite不僅可以實現(xiàn)url 重寫,還可以用來設(shè)置301轉(zhuǎn)向,下面分別是三個版本的ISAPI_Rewrite對應的帶www的域名301轉(zhuǎn)向到不帶www域名的代碼:

1. 將不帶www的頂級域名301重定向到帶www的域名

# ISAPI_Rewrite 2.x 版本
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
RewriteCond Host: ^farlee\.info$
RewriteRule (.*) http\://www\.farlee\.info$1 [I,RP]

# ISAPI_Rewrite 3.0 版本
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
RewriteCond %{HTTP:Host} ^farlee\.info$
RewriteRule (.*) http\://www\.farlee\.info$1 [NC,R=301]

2. 不同域名之間的301轉(zhuǎn)向

# ISAPI_Rewrite 2.x 版本
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
RewriteCond %{HTTP:Host} ^isapirewrite\.com$
RewriteRule (.*) http\://www\.farlee\.info$1 [NC,R=301]

# ISAPI_Rewrite 3.0 版本
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
RewriteCond %{HTTP:Host} ^www\.isapirewrite\.com$
RewriteRule (.*) http\://www\.farlee\.info$1 [NC,R=301]

3. 將頁面301重定向到另外一個頁面

# ISAPI_Rewrite 2.x 版本
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
RewriteRule ^/oldpage.html$ http://farlee.info/newpage.html[I,O,RP,L]

# ISAPI_Rewrite 3.0 版本
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
RewriteRule ^/oldpage.html$ http://farlee.info/newpage.html[NC,L,R=301,O]

注意:ISAPI_Rewrite 1.3是現(xiàn)在國內(nèi)應用得比較多的一個老版本,它可用于url 重寫,但并不適合用來實現(xiàn)真正的301重定向功能。建議下載最新的ISAPI_Rewrite 3.0 版本。在 url轉(zhuǎn)發(fā)和301轉(zhuǎn)向(重定向跳轉(zhuǎn))的實現(xiàn) 這篇文章介紹了一段ISAPI_Rewrite 1.3 的重定向代碼,這段代碼在IIS下對域名重定向雖然能夠順利跳轉(zhuǎn),但是返回的仍然是302 HTTP header,而不是301 狀態(tài)碼。而且該段代碼用于301重定向后,在blog中的其他頁面都會跳轉(zhuǎn)到首頁。

這樣設(shè)置以后,你的windows iis 也能實現(xiàn)301重定向了,不管是Google 和百度搜索引擎都不會有因為帶有www和不帶www的域名而產(chǎn)生重復頁面問題了。

PHP 301 重定向代碼

301重定向也可以在php文件中通過加入php header來實現(xiàn),代碼如下:

<?php
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: http://farlee.info/newpage.html”);
exit();
?>

ASP 301 重定向代碼

<%@ Language=VBScript %>
<%
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”, http://farlee.info
%>

ASP.NET 301 重定向代碼

<script language=”c#” runat=”server”>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(“Location”,http://farlee.info);
}
</script>

ColdFusion 301 重定向代碼

<.cfheader statuscode=”301″ statustext=”Moved permanently”>
<.cfheader name=”Location” value=”http://farlee.info/newpage.html”>

CGI Perl下的301轉(zhuǎn)向代碼

$q = new CGI;
print $q->redirect(“http://farlee.info”);

JSP下的301轉(zhuǎn)向代碼

<%
response.setStatus(301);
response.setHeader( “Location”, “http://farlee.info” );
response.setHeader( “Connection”, “close” );
%>

沒想到這篇文章寫了這么長,有那么多種301轉(zhuǎn)向方法供我們選擇,我們還要依賴域名url轉(zhuǎn)發(fā)功能干什么呢?

來源:網(wǎng)絡搜集//所屬分類:負載集群教程/更新時間:2013-04-14
相關(guān)負載集群教程