日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

301轉(zhuǎn)向代碼合集

 土里小伙夫 2011-06-26

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./articles/301/"
%>

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./articles/301/");
}
</script>

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

header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www./articles/301/");
exit();

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

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

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

<%
response.setStatus(301);
response.setHeader( "Location", "http://www./" );
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} ^ [NC]
RewriteRule ^(.*)$ http://www./$1 [L,R=301]

2)重定向到新域名

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ http://www./$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.
DocumentRoot /home/lesishu
</VirtualHost>

<VirtualHost *:80>
ServerName
RedirectMatch permanent ^/(.*) http://www./$1
</VirtualHost>

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

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

  1. http://www./tools/headers.asp
  2. http://www./seo-tool/redirect-check/

作者:樂思蜀

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請遵守用戶 評(píng)論公約

    類似文章 更多