PHP: using $SERVER[] to return the current directory, regardless of "nice urls"
<p>I am trying to return the current directory of a file in php, regardless what it says in the browser bar. I have tried:</p>

<pre><code>echo $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
</code></pre>

<p>If the url is </p>

<pre><code>http://example.com/directory1/directory2/var1/var2/var3 
</code></pre>

<p>the above code returns </p>

<pre><code>example.com/directory1/directory2/var1/var2/var3
</code></pre>

<p>even though var1/var2/var3 are <code>GET_[]</code> variables tamed by a htaccess RewriteRule. Is there a decent way to get the directory? in the case above I would like to return:</p>

<pre><code>example.com/directory1/directory2/
</code></pre>

<p>thanks.</p>
