Get URL with an if statement PHP
<p>I am trying to get URL path and to save it as variable...</p>

<pre><code>$setURL = true;
$getDomain = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$getSubdomain = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

if ($setURL === true) {
    $result = 'http://'.parse_url($getDomain, PHP_URL_HOST) . '/';
    echo 'get domain';
} else {
    $result = 'http://'.parse_url($getSubdomain, PHP_URL_HOST).parse_url($getSubdomain, PHP_URL_PATH);
    echo 'get subdomain';
}

$siteURL = $result;
</code></pre>

<p>So basically if I defined variable $setURL = true; it will return correct URL for simple domain ... <a href="http://domain-name.com" rel="nofollow">http://domain-name.com</a></p>

<p>However else does not work as I want to... else is there for subdomains. So if I set $setURL = false; it should return following... <a href="http://domain-name.com/path/" rel="nofollow">http://domain-name.com/path/</a></p>

<p>But unfortunately it return more then that... It returns anything I type as URL...
<a href="http://domain-name.com/path/something/index.php" rel="nofollow">http://domain-name.com/path/something/index.php</a> it will return all of that as URL!</p>

<p>Please help me to fix this as I don't have any ideas how I could manage to make it.</p>
