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 - 2012, all rights reserved

Document last modified on Sat Aug 20 2:37:46 PDT 2011.

Navigation

STOP THE GOOGLE MONSTER!

Use DuckDuckGo!

DuckDuckGo search engine

Homepage

Tools

AdSense Calculator Tool
compare 2 strings
md5 online tool
htmlspecialchars(htmlentities()) online tool
htmlspecialchars online tool
remove non-ASCII characters from string online tool
return headers of a website
sha1 online tool
spam free email inbox tool
strtolower PHP function online
SEO Friendly URL's
urldecode online tool
urlencode online tool
your browser information

Spam

Spam Bots Database

Web Tips and Servers

301 Redirect
AvelSieve Script Data Length Problem and Fix
ASCII Symbols
FH_DATE_PAST_20XX
Find Packages with Yum
Password Protect /usage/ Directory on GoDaddy Dedicated Server
ping returns "connect: Network is unreachable"
PHP eaccelerator Problems
Reinstall All Packages with Yum
Removing Old Unused Linux Kernels
Restart Apache and MySQL on Fedora

Articles

About Infolinks
About the Title Tag
Amazon vs. AdSense
AutomaticBacklinks.Com
Buying Images for Websites
Chitika Sucks
Content of (for) Webpages
Domain Name Suggestion
Donations and Quality Links
Doors.txt;6 Spam
Donations for Cross-Linker Development
Google's Panda Explanation and Recovery Tips
HTTP Headers Checker Tool
Invalid Submissions by SEO Experts
Is it Necessary to Submit Websites into Search Engines?
MFA Websites
My Articles
Myths About Links
Natural Link Building
Optimised Articles
PayPerPost Experience
Power of Link Building
Previous Core Updates
Selling Links
Selling Links at Forums
Selling Websites
Spamming WordPress
Thebacklinkbuilders.com
Thevaults.net

Photography

Alfa Romeo Giulietta
Dogs and Fun
Ducks Pictures
Pictures of a Forest in Autumn
Trees and Moss Pictures

Others

Links to Other Websites
About Jan Hvizdak
Contact Jan
My Services