P
P
Pochemu4ka2018-03-12 03:51:56
htaccess
Pochemu4ka, 2018-03-12 03:51:56

htaccess and noob) what to do?

Good afternoon!
I need a little help, I want to understand a couple of points.
Pts often meet such a project structure:
-2 htaccess files, one in the root folder, the second in the public folder.
The content of the root file is something like this:
////
RewriteEngine On
RewriteRule ^(.*)$ /public/$1
//// Public
file:
////
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !- f
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
////
Actually, the essence seems clear to me - redirection of all requests to the index.php file (except folders and files)
But!
1. Why can't the redirection be done immediately in the root file?
Well, something of the format /public/index.php
Why do I need to create a second file in the public folder?
2. Why do we need these "$1" things?
It seems like they explain that everything from brackets with regular expressions gets there, but why?
If we want to work with requests that come to us, it seems like there are a bunch of things in the format "$_SERVER['QUERY_STRING']" and "$_SERVER['REQUEST_URI']"
Why do we need any other variables?
Can anyone explain better?
Thank you)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2018-03-12
@shambler81

Most likely you have a problem with hosting, someone could not normally put the site not in public, or make a normal root document, as a result, I had to wind a crutch on top with another .htaccess that already threw everything into public

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question