You need to implement MVC without frameworks. In general, in the .htaccess file everything is redirected to index.php

 RewriteEngine On RewriteRule .* index.php [L] 

There load.php

 ini_set('display_errors', 1); require_once 'load.php'; 

And in it components MVC are loaded and routing is started

 require_once 'core/route.php'; require_once 'core/model.php'; require_once 'core/view.php'; require_once 'core/controller.php'; //Запуск роутинга Route::start(); 

Routing takes the url and breaks it, here is the route.php

 class Route { static function start() { // контроллер и действие по умолчанию $controller_name = 'Main'; $action_name = 'index'; $routes = explode('/', $_SERVER['REQUEST_URI']); // получаем имя контроллера if ( !empty($routes[1]) ) { $controller_name = $routes[0]; } // получаем имя экшена 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 = "models/".$model_file; if(file_exists($model_path)) { include "models/".$model_file; } // подцепляем файл с классом контроллера $controller_file = strtolower($controller_name).'.php'; $controller_path = "controllers/".$controller_file; if(file_exists($controller_path)) { include "controllers/".$controller_file; } else { /* правильно было бы кинуть здесь исключение, но для упрощения сразу сделаем редирект на страницу 404 */ //Route::ErrorPage404(); echo 123; } // создаем контроллер $controller = new $controller_name; $action = $action_name; if(method_exists($controller, $action)) { // вызываем действие контроллера $controller->$action(); } else { // здесь также разумнее было бы кинуть исключение //Route::ErrorPage404(); echo 123; } } function ErrorPage404() { $host = 'http://'.$_SERVER['HTTP_HOST'].'/'; header('HTTP/1.1 404 Not Found'); header("Status: 404 Not Found"); header('Location:'.$host.'404'); } } 

In general, the project is located in the createownmvc folder and when I createownmvc http: // localhost / createownmvc / prints 123, as it should, because I don’t have such a controller. But if I try to go somewhere like localhost / createownmvc / somethink then it does not output 123 and I get an error from apache itself, that is, the routing does not catch this url and does not try to find the createownmvc controller with somethink method, it’s just Apache

 Not Found The requested URL /createownmvc/somethink was not found on this server. Apache/2.4.18 (Ubuntu) Server at localhost Port 80 

So the question is, How can I make the routing catch such url? And now, when you enter http: // localhost / createownmvc / routing, it is looking for a controller to createownmvc, how to change it so that you can search for controllers like http: // localhost / createownmvc / controller / action ?

Closed due to the fact that off-topic participants cheops , aleksandr barakin , user194374, rdorn , Bald Aug 26 '16 at 7:42 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - cheops, aleksandr barakin, Spirit of the community, rdorn, Bald
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d you try to add before RewriteRule .* index.php [L] ? - Visman
  • @Visman Added, but nothing has changed, as far as I remember, they put a kind of restriction so as not to add too much, so I removed them - to add everything - Vladimir Goncharuk
  • It is not clear what the ICC is with, if the Apache - Ipatiev gives an error
  • 2
    @Vladimir, you have .htaccess turned off in apache. ru.stackoverflow.com/questions/362642/… apache.ru/docs/fishki.html#AllowOverride - Visman
  • one
    And if I did a music site, would I go to the conservatory with this error? - Ipatiev

0