I'm a .NET developer (desktop apps & mobiles) trying to get on the web that I found the best PHP because it's a free Lang and its IDE's are light. I created my MVC pattern (for being a beginner I prefer not to use frameworks) and the local machine is ball show. But why when I migrate it to a server gives a problem on the routes? Stop changing page, just keep DEFAULT (Home). What's wrong with my code?
public static function route($url) {
// my default controller
define('DEFAULT_CONTROLLER', 'Home');
// controller
$controller = (isset($url[0]) && $url[0] != '') ? ucwords($url[0]) : DEFAULT_CONTROLLER;
$controller_name = $controller;
array_shift($url);
// action
$action = (isset($url[0]) && $url[0] != '') ? $url[0] . 'Action': 'indexAction';
$action_name = $controller;
array_shift($url);
$queryParams = $url;
$dispatch = new $controller($controller_name, $action);
if (method_exists($controller, $action)) {
call_user_func_array([$dispatch, $action], $queryParams);
} else {
header("Location: ../_404");
}
}
}
.htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(config|core|css|js|fonts|robots\.txt)
RewriteRule ^(.+)$ index.php/$1 [L]