Thanks DJMaze and sde,
I have included both your code as it was great advice to cover all bases.
When I echo'd it out it was
www.mydomain.com, However it kept redirecting rather then letting through
www.mydomain.com or mydomain.com so I tried
PHP Code:
if($host != "mydomain.com" && $host != "www.mydomain.com"){
and tried
if($host != "mydomain.com" || $host != "www.mydomain.com"){
but it redirected each time, so I ended up with
PHP Code:
if($host != "www.mydomain.com"){
As it should always be this generally and it works fine.
Unless they navigate to the site using
http://mydomain.com in which case the first link they click on will redirect them, or if they use the search box on the homepage that will redirect them.
Above it I added DJMazes check (very good point!). Thank you both very much.