pc홈페이지&모바일홈페이지 연동 소스 중에서.. 정보
pc홈페이지&모바일홈페이지 연동 소스 중에서..본문
<?php
if (preg_match('/(iPhone|Android|iPod|BlackBerry|IEMobile|HTC|Server_KO_SKT|SonyEricssonX1|SKT)/',
$_SERVER['HTTP_USER_AGENT']) ) {
define('BROWSER_TYPE', 'M'); // mobile
} else {
define('BROWSER_TYPE', 'W'); // web (iPad 는 웹으로 간주)
}
if(BROWSER_TYPE == "M")
{
// 모바일 페이지
}else
{
// 웹페이지
}
?>
소스를 어떤 파일에 옴겨야되나요 맨위쪽에 옴겨야되는지 구체적으로 좀 알려주세요.부탁드립니다.
_common.php .ftpmessage index.html index.php
시작에 쓰이는 파일은 이거 총4개뿐인데 어디에 어떻게 해야되는지 몰라서요.
모바일페이지, 웹페이지는 사이트 주소를 넣어야되나요??
추천
0
0
댓글 4개
개인적으로는 인덱스에 넣고 저기서 한가지 추가하면 pc버전으로 보기 누르면 쿠키로 사용자원하는 모드로 변경시켜주면 좋을듯하네요

모바일 페이지가 index.php 라 가정하고, 웹페이지가 index.html 로 가정하고 적어봅니다
-----------------------
<?php
if (preg_match('/(iPhone|Android|iPod|BlackBerry|IEMobile|HTC|Server_KO_SKT|SonyEricssonX1|SKT)/',
$_SERVER['HTTP_USER_AGENT']) ) {
define('BROWSER_TYPE', 'M'); // mobile
} else {
define('BROWSER_TYPE', 'W'); // web (iPad 는 웹으로 간주)
}
if(BROWSER_TYPE == "M")
{
<? header("location:index.php"); ?>
}else
{
<? header("location:index.html"); ?>
}
?>
-----------------------
<?php
if (preg_match('/(iPhone|Android|iPod|BlackBerry|IEMobile|HTC|Server_KO_SKT|SonyEricssonX1|SKT)/',
$_SERVER['HTTP_USER_AGENT']) ) {
define('BROWSER_TYPE', 'M'); // mobile
} else {
define('BROWSER_TYPE', 'W'); // web (iPad 는 웹으로 간주)
}
if(BROWSER_TYPE == "M")
{
<? header("location:index.php"); ?>
}else
{
<? header("location:index.html"); ?>
}
?>
index.html파일을 먼저 읽기때문에 index.html파일에 위 코드가 들어가는게 정석이죠~
index.php: (가정)
if (BROWSER_TYPE == "W")
{
//일반페이지
<script>location.href='index.html';</script>
}
else
{
//모바일페이지
<script>location.href='/m/';</script>
}
이런식으로 하시면됩니다.
if (BROWSER_TYPE == "W")
{
//일반페이지
<script>location.href='index.html';</script>
}
else
{
//모바일페이지
<script>location.href='/m/';</script>
}
이런식으로 하시면됩니다.