How to setup a 301 redirect

301-redirectA 301 redirect is the most efficient and spider/visitor friendly strategy available for web sites that are hosted on servers running Apache / Linux

It’s not hard to implement and it should preserve your search engine rankings for that particular page. If you *have* to change file names or move pages around, it’s the safest option.

A 301 redirect is implemented in your .htaccess file.

PHP Method:

header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.myNewdomain.com");

.htaccess Method:

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^MyNewdomain.com [nc]
rewriterule ^(.*)$ http://www.MyNewdomain.com/$1 [r=301,nc]

Thats it.

Janes Oosthuizen

Author Janes Oosthuizen

Programmer and Tech Junky from Bloemfontein, South-Africa. I have been programming for 8 years in various languages including ( CSS, HTML, jQuery, PHP, MySQL, Wordpress and many other ).

More posts by Janes Oosthuizen

Join the discussion One Comment

Leave a Reply