How to get php request URI without context path?
<p><code>$_SERVER['REQUEST_URI']</code> returns URI with context path.</p>

<p>For example, if the base URL of a website is <code>http://localhost:8080/sitename/</code> (i.e. the context path is sitename), and I use <code>$_SERVER['REQUEST_URI']</code> for <code>http://localhost:8080/sitename/portfolio/design</code>, it will return <code>/sitename/portfolio/design</code>.</p>

<p>I am then exploding the result to interpret my clean URLs:</p>

<pre><code>$page=$_SERVER['REQUEST_URI'];
$segments=explode('/',trim($page,'/'));

$sitePage = $segments[1];//portfolio
</code></pre>

<p>This is working fine for my local testing environment, but on the production server, <code>$segments[1]</code> must become <code>$segments[0]</code></p>

<p>In order to use the same code in development and production, is there any way to get only this part <code>/portfolio/design</code>, i.e. the URI without context path?</p>
