How does a url like http: //localhost/index.php/articles/edit/1/my-first-article work without .htaccess?

I do not understand:

http: //localhost/index.php/articles/edit/1/my-first-article

This URL is mentioned as an example in the Kohana structure documentation . I poked into the files of my installation, and there is no .htaccess, except for my own, which has nothing to do with it.

So, how can this be called index.php, but then, like parameters, the material looks like the added directories in the URL? It does not look "real."

Or is it just how native PHP / Apache / HTTP stuff works? As I understand it, / always says "hey, directory!". For me, absolutely zero sense ... how is this possible? Or do they have somewhere .htaccess that I just don't see / didn't find?

+3
source share
6 answers

In PHP, you can get the data after the file name using a variable $_SERVER["PATH_INFO"]. This allows you to basically get information without using GET variables, which means that Google and co will think you are using static pages. This is basically an alternative mod_rewritethat often turns on, and mod_rewriteoften does not turn on.

This may be obvious to you, but it wasn’t immediately for me, it does not work correctly on index pages if you do not use the file name. For example, http://example.com/test/my/get/paramsit will not work, but it http://example.com/test/index.php/my/get/paramswill.

+2
source

From Apache Docs :

AcceptPathInfo Directive

, , , ( ) . PATH_INFO .

, , /test/ , here.html. /test/here.html/more /test/nothere.html/more / PATH_INFO.

, , - httpd.conf. , , mod_rewrite, / - . .

+10
+1

Kohana, , , .htaccess( ), "" URI :

http://www.domain.com/?/articles/edit/1/my-first-article ( ?)

, Frog, $_SERVER['REQUEST_URI'] ( $_SERVER['HTTP-X-REWRITE-URL'] Windows) '/'.

SEO URI

, .

+1

, , , , , , , ...

...

I saw how people use 404 pages to analyze the request, and then include the desired page with this information.

0
source

See PATH_INFO in CGI Environment Variables .

0
source

Source: https://habr.com/ru/post/1710025/


All Articles