將條件重定向到新的URL,以便我可以編寫「ONE腳本」並將其複製到同一腳本的所有當前舊HTML中。這將有助於那些已經爲舊網址添加書籤並重定向到新網址的用戶。有條件的重定向URL java
我有一箇舊webpeges像
www.oldsite.com/a1.html
www.oldsite.com/a1/5698.html
www.oldsite.com/x1.html
www.oldsite.com/YY1.html
,並希望得到一個用戶的當前URL,並使用location.path和根據路徑(後綴)012重定向到newsite.com即
www.oldsite.com/a1.html
到www.newsite.com/b1.html
www.oldsite.com/a1/5698.html
到www.newsite.com/b1/5698.html
www.oldsite.com/x1.html
到www.newsite.com/99.html
www.oldsite.com/YY1.html
到www.newsite.com/ZZ1.html
我已經嘗試了很多次,但失敗!
既然我是HTML的新人,任何人都可以幫助我嗎? 我的網站舉辦了超過一百個老的HTML!
這裏是我的草案
<html>
<head>
<javascript>
if window.location.path='/al.html'
{
window.location="http://www.newsite.com/b1.html"}
else if window.location.path='/al/5698.html'
{
window.location="http://www.newsite.com/b1/5698.html"}
.........
</script>
</head>
爲什麼在你的問題中使用'java'標記? – 2013-03-05 14:22:20
我猜java腳本可以解決我的問題 – user2136039 2013-03-05 14:51:38