1、用HTML
以下是代碼片段:
<html>
<head>
<meta>
</head>
<body>
Loading…
</body>
</html>
上面代碼意思為:則會在5秒之後重定向到;如果為本身,則每5秒自動刷新1次;如果content=0,則立即重定向。
2、用asp
以下是代碼片段:
<%@Language=”VBScript”%>
<%
Response.Status=“301MovedPermanently”
Response.AddHeader“Location”,“”
%>
或者在空間不支持.htaccess文件,可以通過以下事項
在index.asp或default.asp的最頂部加入以下幾行:
<%
Response.Status="301MovedPermanently"
Response.AddHeader"Location","/"
Response.End
%>
3.用ASP.NET
以下是代碼片段:
<scriptrunat=”server”>
privatevoidPage_Load(objectsender,System.EventArgse)
{
Response.Status=“301MovedPermanently”;
Response.AddHeader(”Location”,”“);
}
</script>
ps:和方法二含義壹樣
4、:用js
以下是代碼片段:
<scriptlanguage=”javascript”>
url=window.location.href;
url=url.replace(””,”“);//把網址代換
window.navigate(url);
</script
5、用PHP
如果空間不支持.htaccess文件,可以通過php代碼來進行301重定向。
在index.php的最頂部加入以下幾行:
<?php
header("HTTP/1.1301MovedPermanently");
header("Location:/");
exit();
?>
6、空間支持
用301智能重定向,空間支持.htaccess文件情況下!
作用:域名更換後舊域名的所有地址自動跳轉到新的域名,就是說所有ttttt.com的數據會自動跳轉到vvvvv.com,如ttttt.com/rewrite.html會轉到vvvvv.com/rewrite.html
用法:將下面的代碼保存為.htaccess上傳到舊域名空間根目錄
RewriteEngineon
RewriteRule^(.*)$/$1[R=301,L]
如果需要跳轉到首頁,將“rewriteRule^(.*)$/$1[R=301,L]”的“$1”刪除即可