2014-12-23 3 views
0

나는 웹 에서이 템플릿을 다운로드하여 이해하기가 쉽습니다. 그것은 당신이 사용하고있는 장치를 모두 탐지하는 데 사용됩니다. 글쎄, 내가 가지고있는 한가지 문제는 index.php 페이지가 어떻게 설정되어 있는지 그리고 REQUEST_URI를 사용하여 링크를 클릭 할 때 하나의 문제 만 가져올 필요가 있는지 알아내는 것입니다. .php 이제는 foobar.php가되어 REQUEST_URI가 쓸모 없게되었습니다. 나는 당신이 링크를 클릭했을 때 index.php 페이지에 머무르고 자했던 것처럼 느낀다. 그러나 그것은 따라야 할 디렉토리를 여전히 보여 주었다. 나는 확신 할 수 없지만 두 파일을 여기에있다. 가난한 설명에 대해 유감스럽게 생각합니다 ... 문법 등은 결코 내 강한 결정이 아니 었습니다.PHP로 URL 요청

오 그래. 그러나 나는 그들의 탐지 장치를 꺼내서 모바일 탐지 장치로 대체했는데 (나는 훨씬 더 좋고 업데이트 된 것을 발견했다.), 그러나 그것들을 사용할 때 여전히이 문제를 나에게 줄 것이다.

Config.php에

<?php 
/* 
* A Design by W3layouts 
Author: W3layouts 
Author URL: http://w3layouts.com 
License: Creative Commons Attribution 3.0 Unported 
License URL: http://creativecommons.org/licenses/by/3.0/ 
* 
*/ 
$current_page_uri = $_SERVER['REQUEST_URI']; 
$part_url = explode("/", $current_page_uri); 
$page_name = end($part_url); 
echo $current_page_uri; 
echo $page_name; 
$email_id = "[email protected]"; 
?> 

Index.php는

<?php 
/* 
* A Design by W3layouts 
Author: W3layouts 
Author URL: http://w3layouts.com 
License: Creative Commons Attribution 3.0 Unported 
License URL: http://creativecommons.org/licenses/by/3.0/ 
* 
*/ 
/* 
include "app/config.php"; 
include "app/detect.php";*/ 
include "app/config.php"; 
require_once 'app/Mobile_Detect.php'; 
$detect = new Mobile_Detect; 

$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer'); 
$scriptVersion = $detect->getScriptVersion(); 
if ($deviceType == "tablet" || $deviceType == "phone") { 
    $browser_t = "smartphone"; 
} 
elseif ($deviceType == "computer") { 
    $browser_t = "web"; 
} 

if ($page_name=='') { 
    include $browser_t.'/index.html'; 
    } 
elseif ($page_name=='index.html') { 
    include $browser_t.'/index.html'; 
    } 
elseif ($page_name=='technology.html') { 
    include $browser_t.'/technology.html'; 
    } 
elseif ($page_name=='blog.html') { 
    include $browser_t.'/blog.html'; 
    } 
elseif ($page_name=='about.html') { 
    include $browser_t.'/about.html'; 
    } 
elseif ($page_name=='contact.html') { 
    include $browser_t.'/contact.html'; 
    } 
elseif ($page_name=='single-page.html') { 
    include $browser_t.'/single-page.html'; 
    } 
elseif ($page_name=='404.html') { 
    include $browser_t.'/404.html'; 
    } 
elseif ($page_name=='contact-post.html') { 
    include 'app/contact.php'; 
    } 
else 
    { 
     include $browser_t.'/404.html'; 
    } 

?> 
+0

브라우저 서버 측 검색은 히트 앤 미스 비즈니스입니다. 다른 화면 크기를 수용하려는 경우 대신 웹 사이트 레이아웃을 응답으로 만드십시오. – tyteen4a03

+0

예. 나는 평소에하고 있지만 새로운 것을 시도하려고했지만, 지금은 그들이하는 일을 이해하려고 노력하고 있습니다. 나는 이것을 다음과 같이 가정합니다. https://translate.google.com/#en/es/hello 어디에서/es가되어야할까요? q = hello 대신/hello입니다. – Matthew

+0

No; 그것은 URL 라우팅입니다. PHP에서 이와 비슷한 것을하고 싶다면 Symfony, Silex, Laravel과 같은 프레임 워크를 사용하는 것이 가장 좋습니다. (분명히 klein.php와 같은 순수 라우팅 유틸리티가 있지만 업계 최고의 사례를 찾아 볼 수도 있습니다) – tyteen4a03

답변

0

나는 때문에 제대로 작동하지 않는 내 서버에 mod_rewrite를 가능하도록 잊어 버렸습니다.