How to get real root url in PHP (without framework) : <p>I have 3 app in one public_html folder:</p>

<ul>
<li>/public_html/myapp_1</li>
<li>/public_html/subfolder/myapp_2</li>
<li>/public_html/subfolder3/small/myapp_3</li>
</ul>

<p>when I run myapp_1 as sample.dev
=> So I got root url: sample.dev</p>

<p>when I run myapp_2 as sample.dev/subfolder
=> So I also got root url: sample.dev</p>

<p>when I run myapp_3 as sample.dev/subfolder3/small
=> I also got root url: sample.dev</p>

<p>But, I want to get:</p>

<ul>
<li>url of myapp_2 as "sample.dev/subfolder"</li>
<li>url of myapp_3 as "sample.dev/subfolder/small".</li>
</ul>

<p>This active will auto get with real container folder (not fixed)</p>

<p>Because I have a common function as:</p>

<p>function getFullAssetUrl('style.css');</p>

<p>This function will return:</p>

<ul>
<li><p>With myapp_1 => sample.dev/style.css</p></li>
<li><p>With myapp_2 => sample.dev/subfolder/style.css</p></li>
<li><p>With myapp_3 => sample.dev/subfolder3/small/style.css</p></li>
</ul>
