Trying to set up the CNC.

This is what .htaccess looks like:

RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule .* index.php?c=$0 [QSA] <FilesMatch "\.(php)$"> Deny from all </FilesMatch> <FilesMatch "index.(php)$"> Allow from all </FilesMatch> 

In the index.php file, the URL is broken down by a slash. And depending on what we have in the URL, connects the desired controller. Everything is working fine.

But there is one problem. When contacting site.ru/index.php, the main page opens. When contacting site.ru/index.php?c=add, it opens the same that opens at site.ru/add.

How to make the site work only on CNC, and when contacting an address like site.ru/index.php ... was there an error 404, or a redirect to the main page?

    1 answer 1

    Solved a problem.

    In index.php I added the following lines:

     //Настройка 404 ошибки для 'index', 'index.php?...' и т. п. ; $root = '/site.ru'; $request_uri = $_SERVER['REQUEST_URI']; $pattern = "/index/i"; preg_match($pattern, $request_uri, $p_m); if (count($p_m) > 0) { //Подключаем контроллер 404 ошибки, в нём есть строчка "header($_SERVER['SERVER_PROTOCOL']." 404 Not Found");" require_once ('c/404.php'); exit(); } 

    Now it works as it should.