2011-03-23 3 views
1

자바와 악의 http-equiv 메타 태그가 결합 된 새 블로그로 이전 블로그를 리디렉션하고 있습니다. 로봇의 중복을 방지하기 위해 나는 또한 추가 한 :자바 스크립트 및 http-equiv로 리디렉션

<meta name="robots" content="noindex" /> 

리디렉션 조각은 다음과 같습니다 :

<!--Execute javascript rediect--> 
<script type="text/javascript"><!--//--><![CDATA[//><!-- 
var url = "http://new_loc.blogspot.com/" 
(document.images) ? location.replace(url) : location.href = url; 
//--><!]]> 
</script> 
<!--If the browser can be bothered to refresh with new content, 
also works if browser has javascript disabled, in mozilla family --> 
<meta http-equiv="refresh" content="0;URL=http://new_loc.blogspot.com/" /> 

이 그러나 당황스러운 할 수 new_loc의 첫 페이지에 깊은 링크를 리디렉션 들어오는 리더 용. 상대 링크가 javascript 및 http-equiv 트릭 모두 변경되지 않은 상태로 유지되기를 바랍니다. 이것을 달성하는 가장 좋은 방법은 무엇입니까?

답변

0

방법 새 URL로 리디렉션 비슷한 스크립트를 사용하여 자바 스크립트에 대한 :

<script> 
var myUrl = location.href; 
var old = /http:\/\/old_loc.blogspot.com/gi; 
var new1='http://new_loc.blogspot.com'; 
myNewUrl = myUrl.replace(old, new1); 
window.location = myNewUrl; 
</script> 

또는 짧은 CUT :

<script> 
var old = /http:\/\/old_loc.blogspot.com/gi; 
var new1='http://new_loc.blogspot.com'; 
window.location = window.location.href.replace(old, new1); 
</script>