SandySynaptik Posted May 21, 2011 Share Posted May 21, 2011 I not sure if this is right place to ask this question. I want to redirect the user from http://example.com to http://www.example.com Something like Google and Facebook does, if you go to facebook.com you will be redirected to www.facebook.com Link to comment Share on other sites More sharing options...
dzhax Posted May 21, 2011 Share Posted May 21, 2011 I not sure if this is right place to ask this question. I want to redirect the user from http://example.com to http://www.example.com Something like Google and Facebook does, if you go to facebook.com you will be redirected to www.facebook.com put this at the top of index.php<? if($_SERVER['SERVER_NAME'] == "example.com") header('Location: http://www.example.com');?> Link to comment Share on other sites More sharing options...
dzhax Posted May 21, 2011 Share Posted May 21, 2011 also if you want it to do it for any pageput this at the top of all pages. <? $urlPrefix = substr($_SERVER['SERVER_NAME'], 0, 4); if($urlPrefix != 'www.') header('Location: http://www.' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);?> also you might want to look into .htaccessI am no help on that though I have a couple threads open on that. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.