php redirect to www This shows how to make a php redirect from “url.com” to “www.url.com”. if (substr($_SERVER['HTTP_HOST'], 0, 4) !== 'www.') { header('Location: '.$protocol.'www.'.$_SERVER['HTTP_HOST'].str_replace('//','/','/'.$_SERVER['REQUEST_URI'])); exit; }
Create a 301 Redirect to a new domain If you change your Domain to a new you should make a redirect from the old to the new.In this case “http://scheinast.eu” is the new domain and on the old server we create a .htaccess file and put this text in: Redirect 301 / http://scheinast.eu/