修改$ _SERVER ['REQUEST_URI'],具体取决于index.php所在的目录

I have a problem here:

I have the application that is running on virutalhost: example.com

The application processes all all reqests example.com/* and they fall into the index.php script where the magic happens further.

The components of magic environment variable $ _SERVER ['REQUEST_URI'], everything works nicely, until I wanted to run the application in a subdirectory: example.com/abc/*

My question is:

How can I modify $ _SERVER ['REQUEST_URI'] with entries in .htaccess after entering the example.com/abc/whatever the index.php script in the $ _SERVER ['REQUEST_URI '] was the entry: /whatever and not /abc/whatever?

I made some research, and slowly come to the conclusion that it is only a modification of the $ _SERVER ['REQUEST_URI'] in a index.php script is the one solution?

Has anyone an idea?

Thank you for any help

Try not to use $_SERVER['REQUEST_URI'] for this type of thing.

Instead use define and then use those definitions throughout your application. So for your subdirectory us this and then use BASE_DIR and BASE_URL throughout your application.

define("BASE_DIR", "/var/www/abc/");
define("BASE_URL", "/abc);

If you then need to move it again this is easily done, because you can just change those two variables and you don't need to worry about making sure $_SERVER['REQUEST_URI'] is right.

define("BASE_DIR", "/var/www/sitename.com/httpdocs/subdir");
define("BASE_URL", "/subdir);

Note you use these definitions like so

echo "The base dir is " . BASE_DIR;