分類:JavaScript

http url redirect 對 SEO 的影響

使用 標籤進行重新導向可能會降低搜尋引擎排名。但如果沒有 URL 值單純只是重新整理頁面則不會影響,網頁重新導向應提供包含新網頁位置的訊息,以及足夠的時間讓使用者閱讀訊息。若網頁重新導向的逾時期間少於五秒,搜尋引擎的排名可能會因此下降。

<meta http-equiv="refresh" content="5;url='http://www.google.com/'" />

若要重新導向網頁,請考慮改用 HTTP 重新導向。HTTP 重新導向較有可能將舊網頁的權威度轉移至新網頁,或是 javascript 來設置!

<script>
setTimeout("window.location.href='http://www.google.com';",1000);
</script>

文章參考: MSDN這個

用 javascript 探測當前網頁位置

假設現在我有個網頁,網址是:http://functionlab.org:80/tools/tcpproxy.php?user=FUNction#showscript
如果這網頁上有以下JavaScript 程式碼

<script type="text/javascript">
    //http://www.w3schools.com/htmldom/dom_obj_location.asp  
    document.write("location.href : "+location.href+"<br/>");
    document.write("location.protocol : "+location.protocol+"<br/>");
    document.write("location.hostname : "+location.hostname+"<br/>");
    document.write("location.host : "+location.host+"<br/>");
    document.write("location.port : "+location.port+"<br/>");
    document.write("location.pathname : "+location.pathname+"<br/>");
    document.write("location.search : "+location.search+"<br/>");
    document.write("location.hash : "+location.hash+"<br/>");
</javascript>

則該網頁上會顯示:
location.href : http://functionlab.org:80/tools/tcpproxy.php?user=FUNction#showscript
location.protocol : http
location.hostname : functionlab.org
location.host : functionlab.org:80
location.port : 80
location.pathname : /tools/tcpproxy.php
location.search : ?user=FUNction
location.hash : #showscript

本文參考這篇這篇