How to strip a GET property from the URL using PHP
<p>I have the following function that get's the current page URL:</p>

<pre><code>&lt;?php

    // get current page url
    function currentPageUrl() {

        $pageURL = 'http';

        if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}

        $pageURL .= "://";

        if ($_SERVER["SERVER_PORT"] != "80") {
            $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
        }
        else {
            $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
        }


        echo $pageURL;

    }

?&gt;
</code></pre>

<p>Which prints:</p>

<p><a href="http://localhost/gallery.php?id=23&amp;type=main" rel="nofollow">http://localhost/gallery.php?id=23&amp;type=main</a></p>

<p>I want to remove "&amp;type=main" which is present in the url. So before echoing $pageURL I add the following line:</p>

<pre><code>$pageUrl = preg_replace("&amp;type=main", "", $pageURL);
</code></pre>

<p>But it still returns the full url including type=main. How can I get rid of that from the url?</p>
