How to compare current website url to the website url in the database?
<p>What is the best way to compare a current website url in your address bar with the url saved in the database?</p>

<p>What I want to do is make it so if the url in the database is <a href="http://www.domain.com/" rel="nofollow">http://www.domain.com/</a> but the user types in <a href="http://domain.com/" rel="nofollow">http://domain.com/</a> it will 301 redirect to the domain saved in the database... </p>

<p>The same will happen if the domain saved is <a href="http://domain.com/" rel="nofollow">http://domain.com/</a> and they enter <a href="http://www.domain.com/" rel="nofollow">http://www.domain.com/</a>... I want it to redirect to <a href="http://domain.com/" rel="nofollow">http://domain.com/</a></p>

<p>I don't want to do this with htaccess. I want to actually build it into my PHP script. Wordpress has done this but I can't find the code that they use to do it...</p>

<p>Thanks for your help!</p>
