Better way to do this in PHP
<p>I currently have my htaccess file set to remove the file type so</p>

<pre><code>www.example.com/home.php
</code></pre>

<p>would become,</p>

<pre><code>www.example.com/home
</code></pre>

<p>I need to compare the url with one that I have saved in the database, I do this by,</p>

<pre><code>if ($_SERVER['QUERY_STRING']) {
    $pageURL = str_replace('.php', '?', 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . $_SERVER['QUERY_STRING']);
}
else {
    $pageURL = substr('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'], 0, -4);
}
</code></pre>

<p>When I save the url in the database it gets saved as the current page url after the htaccess file has removed the .php, it is inserted using jquery ajax.</p>

<p>When I come to compare it, I need this to make it match in php as php doesn't take into account the htaccess changes.</p>

<p>Is there a better way to do this?</p>
