« Thought of the day | Home | Benefit of running an online business #32 »
Top 10 ways to create a 301 redirect
Michael | October 17, 2007
Tonight I redirected a new domain my brother-in-law purchased back to his main site. He and his wife are chiropractors in Ottawa (just setup, may 401 till it’s propogated!) and the new domain is a little shorter and easier to type in than their full domain name (PrestonFamilyChiropractic.ca).
So I thought I would take the time to talk about an important SEO tool…
The 301 Redirect
Generally speaking if you’re moving domains
(and therefore changing post permalinks) or changing blog categories etc, you’re going to want to use a 301 redirect.
A 301 redirect tells the search engines that the page in question has PERMANENTLY moved. In most cases it’s the best and most Search Engine friendly method for redirecting web pages as it’ll go a long way towards preserving your hard earned search engine juice.
So, without further adieu:
The Top 10 Methods to Create a 301 Redirect
(Do I have to mention that you need to REPLACE www.the-new-url.com in the examples below with the actual domain name you want to redirect TO?)
1. JSP
<%
response.setStatus(301);
response.setHeader( “Location”, “http://www.the-new-url.com/” );
response.setHeader( “Connection”, “close” );
%>
2. PHP
<?
Header( “HTTP/1.1 301 Moved Permanently” );
Header( “location: http://www.the-new-url.com/” );
?>
3. IIS
From internet services manager, right click on the file or folder you wish to redirect; Select the “redirection to a URL” radio button and enter the new url. Place a checkmark for “The exact url entered above” and “A permanent redirection for this resource”
4. ASP
<%@ Language=VBScript %>
<%
Response.Status=”301 Moved Permanently”;
Response.AddHeader(”Location”,”http://www.the-new-url.com/”);
%>
5. Ruby on Rails
def old_action
headers["Status"] = “301 Moved Permanently”
redirect_to “http://www.the-new-url.com/”
end
6. .NET
<script runat=”server”>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(”Location”,”http://www.the-new-url.com/”);
}
</script>
7. CGI PERL
$q = new CGI;
print $q->redirect(”http://www.new-url.com/”);
8. ColdFusion<.cfheader statuscode=”301″ statustext=”Moved permanently”>
<.cfheader name=”Location” value=”http://www.the-new-url.com/”>
9. .htaccess *
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.the-new-url.com/$1 [R=301,L]
* Ensure Apache Mod-Rewrite moduled is enabled on your account
10. HTML *
<HTML>
<Body>
<a href=`http://www.the-new-url.com/`>Click Here to Go to My Other Site</a>
</Body>
</HTML>
* I don`t recommend the HTML method as it’s not REALLY a 301 redirect!
(photo above from flickr.com)
| 2.9 |
Topics: SEO |
Related Posts:














Add New Comment
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks
(Trackback URL)