-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
27 lines (27 loc) · 1.42 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!DOCTYPE html> <html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>도메인 변경으로 인한 포워딩</title>
<link rel="canonical" href="https://blog.tadadakcode.com">
<!-- 1. 표준 도메인지정 -->
<script type='text/javascript'>
var dest = "https://blog.tadadakcode.com"; // 2. 옮겨갈 새로운 도메인 지정
function canonicalLink() {
var link = document.getElementsByTagName("link")[0];
link.setAttribute('href', dest + location.pathname);
document.head.appendChild(link); // 3. 포스트 주소가 포함된 canonical을 지정함
}
function domainRedirect() {
var origin = location.origin; // 4. 접속한 정보에서 도메인정보를 확보
var href = location.href; // 5. 접속한 정보에서 도메인이 포함된 포스트 주소를 확보
var destination = href.replace(origin, dest); // 6. 접속한 도메인정보를 옮겨갈 새로운 도메인 주소로 치환
location.href = destination; // 7. 이동
}
// 실행
canonicalLink();
domainRedirect();
</script>
</head>
<body> 도메인 변경으로 인한 포워딩 합니다. </body>
</html>