php 리다이렉트 채택완료
무버블타입이라는 플랫폼을 쓰고 있습니다.
PC와 스맛폰 사이트가 별도로 만들어져 있고
TOP페이지 (사이트주소)로 이동하면
사이트주소/s/ 폴더 내로 이동하도록 php가 입력되어있습니다.
(제가 작업한 사이트가 아니라서 내용물을 전혀 모릅니다 ㅠ )
아래와 같습니다.
</span> </p><p><span style="font-family: 나눔고딕, NanumGothic;"><?php</span></p><p><span style="font-family: 나눔고딕, NanumGothic;">$redirect_server=$_SERVER["SERVER_NAME"];</span></p><p><span style="font-family: 나눔고딕, NanumGothic;">$redirect_ua=$_SERVER['HTTP_USER_AGENT'];</span></p><p><span style="font-family: 나눔고딕, NanumGothic;">$redirect_mode=isset($_GET['mode']) ? $_GET['mode'] : '';</span></p><p><span style="font-family: 나눔고딕, NanumGothic;">$redirect_path=dirname($_SERVER["SCRIPT_NAME"]);</span></p><p><span style="font-family: 나눔고딕, NanumGothic;">//$redirect_file=basename($_SERVER["SCRIPT_NAME"]);</span></p><p><span style="font-family: 나눔고딕, NanumGothic;">$redirect_file='index.php';</span></p><p><span style="font-family: 나눔고딕, NanumGothic;">$redirect_todir='/s/';</span></p><p><span style="font-family: 나눔고딕, NanumGothic;">$redirect_url=$redirect_path.$redirect_todir.$redirect_file;</span></p><p><span style="font-family: 나눔고딕, NanumGothic;">if((strpos($redirect_ua,'iPhone')!==false)||(strpos($redirect_ua,'iPod')!==false)||(strpos($redirect_ua,'Android')!==false)) {</span></p><p><span style="font-family: 나눔고딕, NanumGothic;">if($redirect_mode!='pc') {</span></p><p><span style="font-family: 나눔고딕, NanumGothic;">header("Location: ".$redirect_url);</span></p><p><span style="font-family: 나눔고딕, NanumGothic;">exit();</span></p><p><span style="font-family: 나눔고딕, NanumGothic;">}</span></p><p><span style="font-family: 나눔고딕, NanumGothic;">}</span></p><p><span style="font-family: 나눔고딕, NanumGothic;">?></span></p><p><span style="font-family: 나눔고딕, NanumGothic;">
그런데 지금 처리하고 싶은 것은,
메인페이지 뿐 아니라,
각 게시글이
사이트주소/topics/001.html - PC
사이트주소/s/topics/001.php - 스마트폰
요렇게 되는데 각 게시글의 주소를 입력했을 때에도
기기에 따라 분별해서 들어가졌으면 합니다.
위의 php내용을 수정해서 넣으면 될까 싶어
</span> </p><p style="font-size: 14.6667px;"><span style="font-family: 나눔고딕, NanumGothic;">$redirect_file='topic/';</span></p><p style="font-size: 14.6667px;"><span style="font-family: 나눔고딕, NanumGothic;">$redirect_todir='/s/topic';</span></p><p style="font-size: 14.6667px;"><span style="font-family: 나눔고딕, NanumGothic;">
요부분을 이렇게 해봤는데 잘못움직이더라고요...
혹시 아는 분 계신가요?
아까는 htaccess로 될까 싶어 해봤는데 그것도 모르겠고
골치 아프네요 ㅠ ㅠ
리다이렉트 시키고 싶은 주소
사이트주소/topic/001.html
요거가
사이트주소/s/topic/001.php
요런식으로 밖에 있으니 방법을 모르겠어서... (상위폴더로 가는 법?)
답변 3개
</p><p>if (pc일때) {
$redirect_file='/topics/001.html';
}else{
$redirect_file='/s/topics/001.php';
}</p><p>
이부분을 몽땅 넣어도 될듯 싶네요.
</p><p>$redirect_file='index.php';
$redirect_todir='/s/';
$redirect_url=$redirect_path.$redirect_todir.$redirect_file; </p><p>
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
아무리 검색해봐도 제가 처리하기에는 부족해보여
외부 개발자에게 넘겨버렸습니다 ㅠ ㅠ...
지금 여러가지 검색어로 막 검색해보고 있습니다 하하하