【问题标题】:Frontcontroller help前控制器帮助
【发布时间】:2010-11-08 12:51:24
【问题描述】:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]

php

<?php

$pagesDir = "pages";

// Get the request
$page = $_SERVER['REQUEST_URI'];   

// Strip the first slash
$page = substr($page, 1);

// Prevent access to higher level folders
$page = str_replace('..', '', $page);    

// Do some mapping to actual files in a subfolder
$page = "$pagesDir/$page";    

// Serve an error page if not found
if (!file_exists($page)) {
$page = "$pagesDir/error.html";
}

// Prevent anything from being output until it is ready
ob_start();
include($page);
$contents = ob_get_clean();

// Use a template with the variable $contents where you want the page's content to go
ob_start();
include($template);
$output = ob_get_clean();
echo $output;

?>

警告:include() [function.include]: 在 C:\wamp\www\index.php 中打开 '' 以包含 (include_path='.;C:\php5\pear') 失败29

【问题讨论】:

  • 我在 pages/name test 中有一个页面,当我尝试调用 mysite.com/test 时它不包含它

标签: php


【解决方案1】:

$template 被评估为一个空字符串,无论如何我都没有看到它在您的 PHP 源代码中的任何地方声明。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-01
    • 2011-02-02
    • 2013-11-12
    • 2011-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多