duanfangbunao36970 2014-12-23 07:32
浏览 18
已采纳

Php url请求

I downloaded this template off the web, very easy to understand. It is used to detect what device you're using and all. Well, just one issue I am having with it is how the index.php page is setup and it uses REQUEST_URI to figure out what file it needs to pull just one issue when you click it link it moves files so instead of it being on index.php it is now on foobar.php resulting the REQUEST_URI to be useless. I feel like it was attempting to stay on the index.php page when you clicked a link, but it still showed the dir it was suppose to follow. I am unsure but here the two files. Sorry for my poor explanation... Grammar and such was/is never my strong suit.

Oh yeah. I did however took out their detect and replaced it with mobile detect (Which I find much better and updated), but it will still giving me this issue when I was using theirs.

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条回答 默认 最新

  • dqrq93879 2014-12-23 19:25
    关注

    I forgot to enable mod_rewrite on my server therefore it wasn't working correctly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 表达式必须是可修改的左值
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题