How to set CNC samopisnogo for website in php?

There is a page site.ru/complex/contact.php
Want the page to open the link site.ru/contact
Trying, but nothing comes out, do not understand the principle of operation. Knowledgeable help please

Write to the file .htaccess file (in the root)
RewriteEngine on
RewriteRule ^contact/$ pages/contact.php[L]
March 19th 20 at 08:53
3 answers
March 19th 20 at 08:55
Correct:
1) redirect all URLs to the index(create a single point of entry)
2) in the index to connect the router
3) in the router to handle the url(for example to break on slashes and look what you've done)
as the most simple variant - in the same place in the router to make an array of matching URLs, plug-ins and to check whether such a key of the url in the list and what to connect in this case.
4) Profit

Incorrect:
1) to Use .htaccess to connect separate files, the rest piling files "as is"
2) In each folder to insert your index.php and steer out of it all the left-wing movements
3) other distortions in the range
1) Redirect all URLs to the index, suppose that
RewriteEngine On 

RewriteCond %{SCRIPT_FILENAME} !-d 
RewriteCond %{SCRIPT_FILENAME} !-f 

RewriteRule ^(.*)$ ./index.php?route=$1


After all www.site.com/ falls into the $_GET['route']

2) in the index to connect the router. What is it like?
3) in the router to handle the url(for example to break on slashes and look what you've done)
as the most simple variant - in the same place in the router to make an array of matching URLs, plug-ins and to check whether such a key of the url in the list and what to connect in this case.

This item is also not know until a router where is it?
4) Profit)) - kendrick_Schneider commented on March 19th 20 at 08:58
@kendrick_Schneider,
1)
RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
RewriteRule !\.(js|ico|gif|jpg|png|css|pdf|mov|mp3|woff2)$ index.php
no parameters in General it is not necessary
2)
in the index to connect the router. What is it like?
The router class (or file in case of procedural noodles) with the functions process the incoming url and mapping the url to a particular action, in the IEC architecture this is usually the controller class and the corresponding action, the noodles just the path to the file to include. Something like this(maximally simplified):
$routes = array(
 '/goto/someaction'=> ",
 '/anotherroute/anotheraction'=> 'someabsolutlyanother.php',
);
$route = explode('?',$_SERVER['REQUEST_URI'])[0];
if(!empty($routes[$route]))$includePath = $includesDir.'/'.$routes[$route];
// below where it should connect include $includePath;
Written on the knee, I hope the General meaning is clear.
accessed at: http://mydomen.tld/goto/someaction will boot somefile.php - jada_Abernat commented on March 19th 20 at 09:01
March 19th 20 at 08:57
RewriteRule ^contact/?$ pages/contact.php[L]
did, but still do not get to this page, remain on the main.
htaccess in the root, tried in the pages folder to transfer, still I am getting link site.ru/contact and remain on the main. How to be? - kendrick_Schneider commented on March 19th 20 at 09:00
@kendrick_Schneider, and as of now is the contents of htaccess in the site root. - Alejandra.Leffl commented on March 19th 20 at 09:03
March 19th 20 at 08:59
contact
and
contact/

this is a different URL

I would have written

RewriteRule ^contact(.*)$ pages/contact.php[L]

Find more questions by tags Processing URL