Php url请求

时间:2014-12-23 07:33:00

标签: php request-uri

我从网上下载了这个模板,很容易理解。它用于检测您正在使用的设备以及所有设备。好吧,我遇到的一个问题是index.php页面是如何设置的,它使用REQUEST_URI来确定当你点击它时只需要拉出一个问题的文件链接它移动文件而不是它在索引上.php它现在在foobar.php上导致REQUEST_URI无用。当我点击一个链接时,我觉得它试图留在index.php页面上,但它仍然显示了它想要遵循的目录。我不确定,但这里有两个文件。对不起,我的解释很糟糕......语法等等是我的强项。

噢,是的。然而,我确实取出了他们的检测并用移动检测取而代之(我发现它更好并且更新了),但是当我使用它们时它仍然会给我这个问题。

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 = "w3layouts@gmail.com";
?>

的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';
    }

?>

1 个答案:

答案 0 :(得分:0)

我忘了在我的服务器上启用mod_rewrite,因此它无法正常工作。