모바일 도메인 m.도메인 으로 자동 넘기기 (2016-11-09 수정) 정보
모바일 도메인 m.도메인 으로 자동 넘기기 (2016-11-09 수정)관련링크
본문
모바일 홈페이지를 이용하는 경우 m 으로 시작하는 도메인으로 자동 넘기고 싶을때
네이버에서 모바일 광고 승인이 거부되었다는 이야기를 듣고 알아보니 http://도메인 으로 모바일 홈페이지가 뜨면 최적화가 안되었다는 거부사유가 뜹니다.
모바일 기기에서 접속할때 http://www.happyjung.com 또는 http://happyjung.com 으로 접속할때 http://m.happyjung.com 으로 넘기는 방법입니다.
이것을 적용하기전에 도메인의 네임서버 설정에서 A 레코드를 추가해야합니다.
A 레코드 추가는 거래하는 웹호스팅사에 문의하세욤.
그누보드5 / 테마 / head.sub.php 의 내용을 이렇게 수정합니다.
< 방법1 >
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<?php
if (G5_IS_MOBILE) {
를 아래와 같이 변경합니다.
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<?php
if (G5_IS_MOBILE) {
$hp_index_url = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
//echo $hp_index_url;
if ($hp_index_url == "happyjung.com/index.php" || $hp_index_url == "www.happyjung.com/index.php") {
?>
<script type="text/javascript">
<!--
location.href = "http://m.happyjung.com"
//-->
</script>
<?php
}
< 개선된 방법2 : 2016-11-09 추가>
<!doctype html>
<html lang="ko">
를 아래와 같이 변경
<?php
// 브라우저 정보로 홈페이지 이동하기
$ua = $_SERVER['HTTP_USER_AGENT']; // 브라우저 정보
if(preg_match('/(iPhone|Android|Opera Mini|SymbianOS|Windows CE|BlackBerry|Nokia|SonyEricsson|webOS|PalmOS)/i', $ua)) {
if ($hp_index_url == "happyjung.com/index.php" || $hp_index_url == "www.happyjung.com/index.php") {
?>
<script type="text/javascript">
<!--
location.href = "http://m.happyjung.com"
//-->
</script>
<?php
}
}
?>
<!doctype html>
<html lang="ko">
네이버에서 모바일 광고 승인이 거부되었다는 이야기를 듣고 알아보니 http://도메인 으로 모바일 홈페이지가 뜨면 최적화가 안되었다는 거부사유가 뜹니다.
모바일 기기에서 접속할때 http://www.happyjung.com 또는 http://happyjung.com 으로 접속할때 http://m.happyjung.com 으로 넘기는 방법입니다.
이것을 적용하기전에 도메인의 네임서버 설정에서 A 레코드를 추가해야합니다.
A 레코드 추가는 거래하는 웹호스팅사에 문의하세욤.
그누보드5 / 테마 / head.sub.php 의 내용을 이렇게 수정합니다.
< 방법1 >
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<?php
if (G5_IS_MOBILE) {
를 아래와 같이 변경합니다.
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<?php
if (G5_IS_MOBILE) {
$hp_index_url = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
//echo $hp_index_url;
if ($hp_index_url == "happyjung.com/index.php" || $hp_index_url == "www.happyjung.com/index.php") {
?>
<script type="text/javascript">
<!--
location.href = "http://m.happyjung.com"
//-->
</script>
<?php
}
< 개선된 방법2 : 2016-11-09 추가>
<!doctype html>
<html lang="ko">
를 아래와 같이 변경
<?php
// 브라우저 정보로 홈페이지 이동하기
$ua = $_SERVER['HTTP_USER_AGENT']; // 브라우저 정보
if(preg_match('/(iPhone|Android|Opera Mini|SymbianOS|Windows CE|BlackBerry|Nokia|SonyEricsson|webOS|PalmOS)/i', $ua)) {
if ($hp_index_url == "happyjung.com/index.php" || $hp_index_url == "www.happyjung.com/index.php") {
?>
<script type="text/javascript">
<!--
location.href = "http://m.happyjung.com"
//-->
</script>
<?php
}
}
?>
<!doctype html>
<html lang="ko">
추천
6
6
댓글 5개
많은 도움이 되었습니다. 감사합니다
이렇게도 해봤습니다.
<script>
if (navigator.userAgent.match(/iPhone/) || navigator.userAgent.match(/iPad/)
|| navigator.userAgent.match(/Android/)) {
location.replace("http://홈페이지 ");
}
</script>
<script>
if (navigator.userAgent.match(/iPhone/) || navigator.userAgent.match(/iPad/)
|| navigator.userAgent.match(/Android/)) {
location.replace("http://홈페이지 ");
}
</script>
자바스크립트에서 agent 정보를 조회해서 넘어가는 것도 좋은 방법이라 생각합니다.
다양한 브라우저와 기기의 agent 정보를 정리한 것이 있으니 그것을 참고해서 agent 조회수를늘리면 더욱 좋은 팁이 되리라 생각됩니다.
https://sir.kr/g5_tip/4946 agent 정보
다양한 브라우저와 기기의 agent 정보를 정리한 것이 있으니 그것을 참고해서 agent 조회수를늘리면 더욱 좋은 팁이 되리라 생각됩니다.
https://sir.kr/g5_tip/4946 agent 정보
감사합니다.
감사합니다