-1
沒有找到類這是我在MVC項目基於請求的URL
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
的.htaccess這是我在控制器文件夾的簡單類
class index {
function __construct()
{
echo "this page is index";
}
}
,這是我的索引頁,我想,當在url中的控制器部分是索引它打印控制器部分和運行類。但它的錯誤:
Undefined index: url
和
require(controllers/.php): failed to open stream: No such file or directory
我的代碼:
$url = $_GET['url'];
$url = rtrim($url,'/');
$url = explode('/',$url);//breaks string to array
require 'controllers/'.$url[0].'.php';
$controller = new index();
print_r($url);
閱讀了約'spl_autoload_register()'和PSR4。而且,這些都不是與MVC切線相關的。 –
您收到的錯誤(實際上只是一個警告)表示您發佈的重寫規則未得到應用。也許你有其他適用於以前的規則? – arkascha