본문 바로가기
쇼핑몰/고도몰

고도몰 | 도메인 리디렉션

by KISCH 2021. 3. 8.
반응형

도메인 변경 시 여러가지 도메인이 존재하게 됩니다. 고도몰 쇼핑몰을 만들고 임시 도메인에서 새로운 도메인으로 변경된 경우를 예로 들어보겠습니다. (xxx는 도메인명)

 

1. 임시 도메인 PC : http://xxx.godomall.com

2. 임시도메인 모바일 : http://m.xxx.godomall.com

3. 새로운 도메인 PC : http://xxx.co.kr

4. 새로운 도메인 모바일 : http://m.xxx.co.kr

 

네이버 검색 등록 시 임시 도메인이 뜨는 경우가 있을 것입니다. 우리는 더 이상 임시 도메인이 사용되지도 노출되지도 않기를 원합니다. 어떻게 리디렉션 해야할까요?

 

 

 

리디렉션

 

1. PC

if(window.location == "http://xxx.godomall.com/") {
	window.location.href = "http://xxx.co.kr";
}

 

2. 모바일

if(window.location == "http://m.xxx.godomall.com/") {
	window.location.href = "http://m.xxx.co.kr";
}

 

3. 무한루프 시

if(window.location == "http://xxx.godomall.com/") {
	window.location.replace("http://xxx.co.kr");
}

 

 

PC, 모바일

 

1. PC

var filter = "win16|win32|win64|mac";
		
if (navigator.platform) {
	// 모바일에서 접속한 경우
	if (filter.indexOf(navigator.platform.toLowerCase())<0) {

	// PC에서 접속한 경우
	} else {
		if(window.location == "http://xxx.godomall.com/") {
			window.location.replace("http://xxx.co.kr");
		}
	}
}

 

2. 모바일

var filter = "win16|win32|win64|mac";
		
if (navigator.platform) {
	// 모바일에서 접속한 경우
	if (filter.indexOf(navigator.platform.toLowerCase())<0) {
		if(window.location == "http://m.xxx.godomall.com/") {
			window.location.replace("http://m.xxx.co.kr");
		}
	// PC에서 접속한 경우
	} else {
		if(window.location == "http://m.xxx.godomall.com/") {
			window.location.replace("http://xxx.co.kr");
		}
	}
}

 

모바일에서 접속한 경우 godomall.com을 새로운 도메인으로 대체 시켜줬습니다.

PC에서 네이버 검색을 했는데 모바일 페이지가 뜨는 경우가 있습니다. godomall.com을 새로운 도메인으로 교체시켜주면서 PC버전으로 접속한 코드입니다.

 

고도몰의 경우 PC 디자인과 모바일 디자인이 따로 개발해야합니다.

1번 코드는 PC 디자인에 outline/_header.html에 들어가는 소스이고 2번 코드는 모바일 디자인에 들어가야할 소스가 되겠습니다. 

 

 

 

 

 

 

다음 시간에는 검색엔진 로봇을 위해 근본적으로 대표 url를 설정하는 방법과 meta 태그 활용에 대해서 알아볼게요. 고생많으셨습니다. 

 

 

 

고도몰도메인리디렉션

반응형

댓글