How Do I Use a 301 Redirect Page?
If you've redesigned any of the pages of your Web site, but want to maintain your current search engine rankings, you can redirect Web site traffic from your old pages to the new pages without losing your rankings using a "301 redirect."
Search engine spiders will transfer your page rank and update any back links to the old page onto the new page when you use a 301 redirect. The code "301" is interpreted as "moved permanently."
For example, you can redirect traffic from oldpage.php (.asp or .jsp) to "http://www.newdomain.com/newpage.html" and retain your search engine ranking and back links.
Use the code below to redirect traffic to your pages using a 301 Redirect.
NOTE: In the code examples below, replace "oldpagename" with the name of your old Web page (the page you want to redirect traffic away from) and replace "newpage.html" with the name of the new Web page to which you want to redirect traffic.
PHP Code - save this as oldpagename.php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.newdomain.com/newpage.html");
exit();
?>
ASP Code - save this as oldpagename.asp
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "http://www.new-url.com"
%>
Coldfusion - save this as oldpagename.cfm
<.cfheader name="Location" value="http://www.newdomain.com/newpage.html">
ASP .NET - save this as oldpagename.aspx
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.com");
}
Redirecting to WWW (htaccess Redirect)
When using a Linux server with the Apache Mod-Rewrite module enabled, you can create a .htaccess file to ensure that all requests to coolexample.com will redirect to www.coolexample.com, where "coolexample.com" is the name of your domain. The .htaccess file needs to be saved in the root directory of your old Web site, which is the same directory as your index file. You can create a .htaccess file with the following code:
rewritecond %{http_host} ^coolexample.com [nc]
rewriterule ^(.*)$ http://www.coolexample.com/$1 [r=301,nc]
Redirecting Using IIS
When using a Windows server, you can redirect to a 301 page using IIS.
To Redirect to a 301 Page Using IIS
NOTE:This only applies to dedicated and virtual dedicated servers.
- In the Internet Services Manager, select the file or folder you want to redirect.
- From the right-click menu, select a redirection to a URL.
- Specify the file name of the page to which you want to redirect.
- Select The exact URL entered above.
- Select A permanent redirection for this resource.
- Click Apply.