I have a small question about 301 redirect and where to put it. Ex. I would like til make a 301 redirect from a www. to a non-www domain.
I found out that the code from non-www to www is: ---------------------------------------------------------------------------------------------- <?php if (substr(getenv('HTTP_HOST'),0,3) != 'www') { header('HTTP/1.1 301 Moved Permanently'); header('Location:http://www.'.$_SERVER['HTTP_HOST']. $_SERVER['REQUEST_URI']); } ?> ---------------------------------------------------------------------------------------------- And i put that into my index.php file in my root dir.
But what do i do if its the other way around (from www to non-www) ? HTACCESS IS NOT AN ISSUE !! It has to be in php code.
Also - did i put the code above into the right file ? According to the link below - i did it right
I Just cant find a way to redirect the other way around Hope you can help me
You can check your 301 - code here: http://www.ragepank.com/redirect-check/