大家好!![](https://zoearth1024moon99nas.direct.quickconnect.to/plugins/editors-xtd/zoearth_insert_emoticons_btn/imgs/fc7e.gif)
![](https://zoearth1024moon99nas.direct.quickconnect.to/plugins/editors-xtd/zoearth_insert_emoticons_btn/imgs/fc7e.gif)
偶而會遇到一些情況需要301轉址
我們先了解 301 轉址的意思是什麼
依據 [HTTP Redirect 301, 302 區別及對SEO的影響] 這篇文章說明
301轉址 是 永久性轉址
302轉址 是 暫時性轉址
所以重點來了
如果你使用 301 轉址
你的瀏覽器會 暫存住這個結果
即使你再修改程式為不轉址
你會發現瀏覽器還是會轉換![](https://zoearth1024moon99nas.direct.quickconnect.to/plugins/editors-xtd/zoearth_insert_emoticons_btn/imgs/c671.gif)
![](https://zoearth1024moon99nas.direct.quickconnect.to/plugins/editors-xtd/zoearth_insert_emoticons_btn/imgs/c671.gif)
所以這點需要很小心
使用header分別為
301轉址:HTTP/1.1 301 Moved Permanently
302轉址:HTTP/1.1 301 Temporarily Moved
在PHP可以這樣寫
$goLink = "http://test.com";//新網址 header("HTTP/1.1 301 Moved Permanently"); header("Location: $goLink");
Joomla3可以這樣寫
$goLink = "http://test.com";//新網址 JResponse::setHeader("HTTP/1.1 301 Moved Permanently"); JResponse::setHeader("Location",$goLink );
給大家參考囉
感恩!![](https://zoearth1024moon99nas.direct.quickconnect.to/plugins/editors-xtd/zoearth_insert_emoticons_btn/imgs/756d.gif)
![](https://zoearth1024moon99nas.direct.quickconnect.to/plugins/editors-xtd/zoearth_insert_emoticons_btn/imgs/756d.gif)
留言板
歡迎留下建議與分享!希望一起交流!感恩!