301跳轉和301重新導向是同一個意思兩種說法。
什麼是301跳轉?
如何做301跳轉
各種環境下重新導向實施代碼
IIS 重新導向
ColdFusion 重新導向
<.cfheader statuscode="301" statustext="Moved permanently">
<.cfheader name="Location" value="http://www.new-url.com">
PHP 重新導向
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?>
ASP 重新導向
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.new-url.com/"
%>
ASP .NET 重新導向
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.com");
}
</script>
JSP (Java) 重新導向
<%
response.setStatus(301);
response.setHeader( "Location", "http://www.new-url.com/" );
response.setHeader( "Connection", "close" );
%>
CGI PERL 重新導向
$q = new CGI;
print $q->redirect("http://www.new-url.com/");
Ruby on Rails 重新導向
def old_action
headers["Status"] = "301 Moved Permanently"
redirect_to "http://www.new-url.com/"
end
老網域名稱重新導向到新網域名稱(htaccess 重新導向)
使用下面代碼建立 .htaccess 檔案,這將確保所有的目錄和您的舊域的網頁會得到正確重新導向到新網域名稱。htaccess檔案需要放在您的舊網站的根目錄下。
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
請替換www.newdomain.com為您實際網域名稱。
除了重新導向,我建議你通知夥伴修改連結並重新連結到您的新網站。
註:此重新導向(htaccess檔案)方法只有在Linux伺服器上使用apache並啟用 Apache Mod-Rewrite才有效。
重新導向 到www (htaccess redirect)
使用下面代碼建立 .htaccess 檔案, 這將確保所有的請求從domain.com 重新定向到 www.domain.com
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
請替換www.newdomain.com為您實際網域名稱。
註:此重新導向(htaccess檔案)方法只有在Linux伺服器上使用apache並啟用 Apache Mod-Rewrite才有效。
重新導向偵查工具
http://www.webconfs.com/redirect-check.php