SandySynaptik Posted September 5, 2011 Share Posted September 5, 2011 How can I redirect the user to example.com to www.example.com?And what if I only want to redirect the homepage? Link to comment Share on other sites More sharing options...
justsomeguy Posted September 5, 2011 Share Posted September 5, 2011 if ($_SERVER['HTTP_HOST'] != 'www.example.com'){ header('Location: http://www.example.com/'); exit();} Link to comment Share on other sites More sharing options...
Man In Tan Posted September 6, 2011 Share Posted September 6, 2011 Just as a note to others reading this topic, this code can also be put in reverse. As a supporter of no-www.org, my site redirects www. requests to the root domain. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.