How to Create a 301 Redirect |
|
The 301 redirect is an efficient means of webpage redirection, to be used when you have redesigned your website. This HTTP code stands for 'moved permanently'. The 301 redirect can be implemented by creating a .htaccess file in Apache servers. The process to create 301 redirects depends on the web server being used. The Meaning of .htaccess FileIn Apache web servers, a check is done in a .htaccess file each time a visitor or spider sends across a request for a web page. This file has instructions directed at particular requests, which could include security, redirection issues and serving error pages. The .htaccess file is situated in the root of the web server. Below is an example of how a particular page can be redirected using an .htaccess file in an Apache server: Redirect 301 /old.html http://www.newsite.com/new.html Redirects are also used by websites to redirect users from the non-www versions of their pages to the www version of their pages, or vice versa. The code below should be placed in the .htaccess to achieve the above redirection. RewriteEngine On RewriteCond %{HTTP_HOST} ^domainname\.com$ [NC]RewriteRule ^(.*)$ http://www.domainname.com/$1 [R=301,L] The .htaccess file should be placed in the root of your old website. Redirecting Web Pages in IISUse the following steps to redirect web pages using IIS:
301 Redirect Within Individual Pages301 Redirect in ASP-VBScriptIf your website is running on IIS, you can use the following VBScript code in your ASP pages to perform the 301 redirect: <%@ Language=VBScript> <% ' Permanent redirection Response.Status = "301 Moved Permanently" Response.AddHeader "Location", "http://www.somacon.com/" Response.End > 301Redirect in PHPThe code below will help you achieve 301 Redirect in PHP: <?php // Permanent redirection header("HTTP/1.1 301 Moved Permanently");header("Location: http://www.somacon.com/");exit(); ?> 301 Redirect in PerlThe code below will help you achieve 301 Redirect in Perl #!/usr/bin/perl -w use strict; print "Status: 301 Moved Permanantly\n"; print "Location: http://somewhere/page.htm\n\n"; exit; 301 Redirect in ColdFusion"301" statustext="Moved Permanently" "Location" value="http://www.somacon.com/" |
Discuss How to Create a 301 Redirect in the forums.
You need to login or register to post comments.


