超簡單網站搬家換網址自動一對一轉址

網站搬家換網址一直都是個麻煩事

由於不是大牌部落客,沒啥流量,所以暫時用的是 Blogger 的網址,心血來潮想換個名字,就遇到了轉址問題,大部分的轉址方式都是將舊網站的連線直接轉到新網站的首頁,但這樣使用者如果是直接連結某篇文章,他只會看到新首頁,相信也沒耐心在新網站上找到原本這篇文章,這個流量就會流失。

所以比較好的方式是能夠一對一的轉址,但一直搜不到有人提供有效率的方法,只好自己研究一下弄了一個簡單的方式來處理。



直接將Blogger的網址改成新的名稱,然後另外開一個 Blogger,採用舊名稱。

接下來用以下內容直接置換整個網站的主題內容就可以了,當然,網址要改成你自己的 ❤️

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html>
  <head>
    <b:skin></b:skin>
  </head>
<body>
  <b:section id='temp'></b:section>

<script type="text/javascript">  
  location.href = "https://angeloeyez.blogspot.com"+location.pathname;
</script>

</body>
</html>



參考資料 ( 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/>");
</script>

留言

這個網誌中的熱門文章

[TCL] 基本語法與指令 - 2. TCL 語法

[TCL] 基本語法與指令 - 1. TCL 簡介

[TCL] 基本語法與指令 - 3. 資料型態