0
嘗試加載任何頁面時,服務器上出現404錯誤。主頁加載沒有問題,在本地主機上都可以正常工作。在服務器上找不到404
我的路線類:
static function start()
{
$controller_name = 'add_task';
$action_name = 'index';
$routes = explode('/', $_SERVER['REQUEST_URI']);
if (!empty($routes[1]))
{
$controller_name = $routes[1];
}
if (!empty($routes[2]))
{
$action_name = $routes[2];
}
$model_name = 'Model_'.$controller_name;
$controller_name = 'Controller_'.$controller_name;
$action_name = 'action_'.$action_name;
$model_file = strtolower($model_name).'.php';
$model_path = "application/models/".$model_file;
if(file_exists($model_path))
{
include "application/models/".$model_file;
}
$controller_file = strtolower($controller_name).'.php';
$controller_path = "application/controllers/".$controller_file;
if(file_exists($controller_path))
{
include "application/controllers/".$controller_file;
}
else
{
Route::ErrorPage404();
}
$controller = new $controller_name;
$action = $action_name;
if(method_exists($controller, $action))
{
$controller->$action();
}
else
{
Route::ErrorPage404();
}
}
function ErrorPage404()
{
...
}
}
我的.htaccess文件:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
我不明白問題出在哪裏