301 and 302 redirect pages

What are 301 and 302 redirect pages ?

301 and 302 redirect pages – You can forward or mask a domain name to redirect it to another website. You can also use either a 301 or 302 redirect.

What are 301 and 302 redirect pages ?

When you redirect your domain name using a 301 redirect, it sends visitors to the specified site with a “301 Moved Permanently” HTTP response. The HTTP 301 response code tells user-agents (including search engines) the location has permanently moved.

301 and 302 redirect pages

If you use a 301 redirect, you can remove the redirect or change it at any time.

A 302 redirect sends visitors to the specified site indicating a “302 Found” HTTP response. As a result the HTTP 302 response code tells user-agents (including search engines) that the location has temporarily moved.

 

A 301 redirect can provide a long-term solution by pointing your domain names to business or affiliate sites. A 302 redirect points your domain name to a temporary page while you build your permanent website. The specific redirects help the search engines distinguish how long your website can be viewed at the current location.

 

If you renamed or moved pages of your website, As a result a 301 redirect lets you automatically redirect visitors and search engine spiders to your new pages while maintaining your search engine ranking.

 

For example, you can redirect traffic from oldpage.php (.asp or .jsp) to “http://www.newdomain.com/newpage.html” and also retain your search engine ranking and back links.

 

Use the code below to redirect traffic to your pages using a 301 Redirect.

 

In the code examples below, replace “oldpagename” with the name of your old Web page from which you want to redirect traffic and replace “newpage.html” with the name of the new Web page to which you want to redirect traffic.

PHP

After adding this code, finally save this as oldpagename.php

<?php>
header("HTTP/1.1  301 Moved Permanently");
header("Location: http://www.newdomain.com/newpage.html");
exit();
?>

ASP

After adding this code, finally save this as oldpagename.asp

<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "http://www.new-url.com"
%>

ASP.NET

After adding this code, finally save this as oldpagename.aspx

<script language="c#" runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.com");\
}
</script>

.htaccess

When using a Linux server with the Apache Mod-Rewrite module enabled, you can also create a .htaccess file to ensure that all requests to coolexample.com will redirect to www.coolexample.com, where “coolexample.com” is your domain. Save the .htaccess file in your old website’s root directory, hence which is the same directory as your index file. You can create a .htaccess file with the following code:

RewriteEngine on
rewritecond %{http_host} ^coolexample.com [nc]
rewriterule ^(.*)$ http://www.coolexample.com/$1 [r=301,nc]

IIS on VPS or dedicated server – 301 and 302 redirect pages

When using a Windows server, you can also redirect to a 301 page using IIS.

  1. Login to Webdomainguru.com. In the Internet Services Manager, select the file or folder you want to redirect.
  2. From the right-click menu, select a redirection to a URL.
  3. Specify the file name of the page to which you want to redirect.
  4. Select The exact URL entered above.
  5. Select A permanent redirection for this resource.
  6. Click Apply.