The 301 Redirect

The Previous Article

Originally this article discussed the 301 redirect, but as I moved it from services-seo.net to janhvizdak.com, I decided to update the content.

The Best Practises

.htaccess 301 Redirect - New Domain Redirect

This is a good choice when you buy a new domain for your old one and you simply copied the source files, so everything in URL's is same except for the domain name. In this case simply put these lines into your .htaccess file:
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^old_domain.tld [nc]
rewriterule ^(.*)$ http://www.new_domain.tld/$1 [r=301,nc]

.htaccess 301 Redirect - Single Page Redirect

Of course, usually you aren't changing domains each month, so a redirect that redirects one page to it's new URL is needed more often. It's easy too, into .htaccess put this line for instance:
redirect 301 /old_page.html http://www.yourdomain.tld/newpage.html
Bear in mind that using some special symbols such as ? may cause problems and if you aren't .htaccess expert, use PHP redirects instead.

PHP 301 Redirect

The 301 redirect done via PHP is what I like the most as things are very easy (unlike .htaccess expressions). Of course, things may get complicated in PHP too and not everything can be resolved via PHP, but anyway I'm using it very often. Here is the PHP code:
<?php
Header("HTTP/1.1 301 Moved Permanently");
Header("Location: http://www.newuri.tld");
exit();
?>
Happy redirecting ;) !

17 January 2010, originally published on October 8, 2007

©Jan Hvizdak 2009, all rights reserved

Navigation

Homepage
301 Redirect
About Infolinks
About the Title Tag
AdSense Calculator Tool
Amazon vs. AdSense
ASCII Symbols
Chitika Sucks
Content of (for) Webpages
Dogs and Fun
Domain Name Suggestion
Doors.txt;6 Spam
Ducks Pictures
FH_DATE_PAST_20XX
Donations for Cross-Linker Development
HTTP Headers Checker Tool
Invalid Submissions by SEO Experts
Links to Other Websites
md5 Online Tool
MFA Websites
My Articles
Myths About Links
Natural Link Building
Optimised Articles
PayPerPost Experience
PHP eaccelerator Problems
Pictures of a Forest in Autumn
Power of Link Building
Previous Core Updates
Restart Apache and MySQL on Fedora
Selling Links
Selling Links at Forums
Selling Websites
SEO Friendly URL's
sha1 Online Tool
Spam Bots Database
Spam Free Email Inbox Tool
Spamming WordPress
Trees and Moss Pictures
About Jan Hvizdak
Contact Jan
My Services