PHP Redirect Code
Using the PHP redirect method requires that you call the “header ()” first before anything else. Nothing else, even an “include ()” statement or an empty space, should be allowed before the “header()” is executed. The code examples below show the right way of implementing this:
<?php header (“http/1.1 301 Moved Permanently”); header (“Location: http://www.developerdrive.com”); ?>
The first header information tries to figure out the HTTP status code that should be sent when missing files are found. The information in the second line is sent back to the browser together with the status code.
Some developers skip the first line entirely and just go with the second line as shown below:
<?php Header (“Location: http://www.developerdrive.com”); ?>
While this redirect may work, it will result in a “302 Moved Temporarily” redirect message instead of a 301 redirect. This is not a Search Engine friendly redirect and should be avoided.
HTML Redirect Code
When redirecting using HTML, you need to ensure that any tricks that are targeted towards Search Engines may get you banned. Ensure that only the code below is placed inside the <Head> and </Head> tags of your HTML code:
<meta http-equiv="Refresh" content="5”; url=http://www.developerdrive.com/">
The “Content=”5”” parameter tells the browser to wait for 5 seconds below redirecting to “DeveloperDrive.com.”
Redirection using .HTACCESS file
.htaccess file is a configuration system file. With this file, you can redirect an entire site to a different URL, a single file to a specific subfolder, or redirect old files to new paths.
Some online SEO resources are able to automatically check if your redirects can be crawled correctly and that the redirects have been set up right. Once you make a redirection, use these tools (e.g. www.webconfs.com) to ensure that your redirects are Search Engine friendly.
Regardless of what method you use, permanent redirects are more search engine friendly than temporary redirects which should be avoided if possible.