V
V
Vadim Stepanenko2018-02-24 14:50:40
PHP
Vadim Stepanenko, 2018-02-24 14:50:40

How to deal with $_SERVER['REQUEST_URI'] XAMPP?

Hello!
I'm analyzing the structure of MVC frameworks by video and ran into such a problem.
I have a local site (localhost/site-folder/site-files)
And when I send a request $_SERVER['REQUEST_URI'], in the response the path along with "site-folder", and therefore the router does not work correctly.
That is, for example, the site has a link localhost/site2/index.php
And in fact (should be) $_SERVER['REQUEST_URI'] = index.php, if index.php is opened, but returns "site2/index.php"
Like correct this situation? Through .htaccess? Via xampp config? All climbed, there is no solution anywhere

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Ernest Faizullin, 2018-02-24
@erniesto77

why use $_
if there is a framework. After all, there can be many problems with direct access.

A
Anton, 2018-02-24
@sHinE

And essentially (should be) $_SERVER['REQUEST_URI'] = index.php

It shouldn't, you have the correct value there. Another thing is that you don't need the /site2/ part.
Either cut off this part before connecting the router (no one bothers to overwrite $_SERVER['REQUEST_URI']), or configure the router so that it understands what works from the folder.
Another option is to register a new domain in httpd-vhosts.conf and wrap it in the hosts file on 127.0.0.1 and enjoy working from the domain root.
Here it depends on what you need - either to work from the folder, or just to make it work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question