$_SERVER['REQUEST_URI'] returns a URI with a path outline.
For example, if the base URL of a website http://localhost:8080/sitename/(i.e. the path to the context is site_name), and I use $_SERVER['REQUEST_URI']for http://localhost:8080/sitename/portfolio/design, it will return /sitename/portfolio/design.
Then I expand the result to interpret my clean urls:
$page=$_SERVER['REQUEST_URI'];
$segments=explode('/',trim($page,'/'));
$sitePage = $segments[1];
This works fine for the local test environment, but on the production server $segments[1]should become$segments[0]
To use the same code in development and production, is there a way to get only this part /portfolio/design, that is, a URI without a context path?
source
share