虛擬目錄 -> 重定向到URL,輸入需要轉(zhuǎn)向的目標(biāo)URL,并選擇“資源的" />

99久久99久久精品免观看,国产精品久久久久国产精品,国产黄色录像视频,免费的黄色毛片,国产一区精品普通话对白,色妞妞成人在线观看,最新aⅴ福利在线观看免费

綠色資源網(wǎng):您身邊最放心的安全下載站! 最新軟件|熱門排行|軟件分類|軟件專題|論壇轉(zhuǎn)帖|廠商大全

綠色資源網(wǎng)

技術(shù)教程
您的位置:首頁服務(wù)器類Web服務(wù)器 → 301轉(zhuǎn)向代碼大合集 包括IIS、apache和PHP程序/asp程序的301轉(zhuǎn)向設(shè)置

301轉(zhuǎn)向代碼大合集 包括IIS、apache和PHP程序/asp程序的301轉(zhuǎn)向設(shè)置

我要評論 2015/03/04 10:30:49 來源:綠色資源網(wǎng) 編輯:downcc.com [ ] 評論:0 點(diǎn)擊:671次

綠色資源網(wǎng)將SEO工作中所需要的301轉(zhuǎn)向代碼,包括程序上(php、asp)和Web服務(wù)器(apache、iis)下設(shè)置都進(jìn)行了整理,收藏并分享,以備查閱。

1、IIS下301設(shè)置

Internet信息服務(wù)管理器 -> 虛擬目錄 -> 重定向到URL,輸入需要轉(zhuǎn)向的目標(biāo)URL,并選擇“資源的永久重定向”。

2、ASP下的301轉(zhuǎn)向代碼

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

3、ASP.Net下的301轉(zhuǎn)向代碼

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

4、PHP下的301轉(zhuǎn)向代碼

header(”HTTP/1.1 301 Moved Permanently”);  
header(”Location: http://www.siawh.com/”);  
exit(); 

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

$q = new CGI;  
print $q->redirect(”http://www.siawh.com/”); 

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

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

7、Apache下301轉(zhuǎn)向代碼

新建.htaccess文件,輸入下列內(nèi)容(需要開啟mod_rewrite):

1)將不帶WWW的域名轉(zhuǎn)向到帶WWW的域名下

Options +FollowSymLinks  
RewriteEngine on  
RewriteCond %{HTTP_HOST} ^downcc.com [NC]  
RewriteRule ^(.*)$ http://www.siawh.com/$1 [L,R=301] 

2)重定向到新域名

Options +FollowSymLinks  
RewriteEngine on  
RewriteRule ^(.*)$ http://www.siawh.com/$1 [L,R=301] 

3)使用正則進(jìn)行301轉(zhuǎn)向,實(shí)現(xiàn)偽靜態(tài)

Options +FollowSymLinks  
RewriteEngine on  
RewriteRule ^news-(.+)\.html$ news.php?id=$1 

將news.php?id=123這樣的地址轉(zhuǎn)向到news-123.html

8、Apache下vhosts.conf中配置301轉(zhuǎn)向

為實(shí)現(xiàn)URL規(guī)范化,SEO通常將不帶WWW的域名轉(zhuǎn)向到帶WWW域名,vhosts.conf中配置為:

<VirtualHost *:80>  
ServerName www.siawh.com  
DocumentRoot /home/itokit  
</VirtualHost>  
 
<VirtualHost *:80>  
ServerName downcc.com  
RedirectMatch permanent ^/(.*) http://www.siawh.com/$1  
</VirtualHost> 

Apache下除了以上2種方法,還有其他配置方法和可選參數(shù),建議閱讀Apache文檔。

301轉(zhuǎn)向情況檢測

http://www.ab173.com/getheader.php

關(guān)鍵詞:301轉(zhuǎn)向,IIS,apache,PHP,asp

閱讀本文后您有什么感想? 已有 人給出評價(jià)!

  • 3 歡迎喜歡
  • 3 白癡
  • 3 拜托
  • 3 哇
  • 2 加油
  • 1 鄙視