Monday, 29 April 2013

301 Redirect iis,php,asp.net,java,Cgiperl,ruby

301 Redirect(What is 301 Redirect)


The 301 redirect is an efficient way of webpage redirection, It is used whan you redesigen website. This HTTP code stands for 'moved permanently' .If you are changing URL of webpage as it is diplayed in search engine results than yous should use a server side 301 rediret. The 301 status code means that a page has permanently moved to a new location.


CONTENTS

  • How to create Redirect
  • How to set up 301 Redirect for
  • 301 Redirect-IIS redirect
  • 301 Redirect-Cold Fusion redirect
  • 301 Redirect-PHP redirect
  • 301 Redirect-ASP Redirect
  • 301 Redirect-ASP.NET Redirect
  • 301 Redirect-JSP(JAVA)Redirect
  • 301 Redirect-RUBY ON RAILS Redirect
  • 301 Redirect-Redirect old domain to new domain

How to create Redirect

The 301 redirect is an efficient way of webpage redirection, It is used whan you redesigen website. This HTTP code stands for 'moved permanently' .If you are changing URL of webpage as it is diplayed in search engine results than you should use a server side 301 rediret. The 301 status code means that a page has permanently moved to a new location.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.BAelow are the details of how to use 301 Redirects on different platforms.

IIS Redirect

  • IT is a very simple five step method
  • First go into your internet services manager, than right click on the file or folder you want to redirect
  • Second is Select the radio titled "a redirection to a URL".
  • Third is Enter the redirection page
  • Fourth is Check "The exact url entered above" and the "A permanent redirection for this resource"
  • Finally Click on 'Apply'

ColdFusion Redirect

<.cfheader statuscode="301" statustext="Moved permanently">
<.cfheader name="Location" value="http://www.new-url.com">

PHP Redirect

<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?>

ASP Redirect

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

ASP .NET Redirect

<script 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>

JSP (Java) Redirect

<%
response.setStatus(301);
response.setHeader( "Location", "http://www.new-url.com/" );
response.setHeader( "Connection", "close" );
%>

CGI PERL Redirect

$q = new CGI;
print $q->redirect("http://www.new-url.com/");

Ruby on Rails Redirect

def old_action
headers["Status"] = "301 Moved Permanently"
redirect_to "http://www.new-url.com/"
end

Redirect Old domain to New domain (htaccess redirect)

(1)First create a .htaccess file with the below code.
(2)Place it into the root directory of your website.
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
(3)Now REPLACE www.newdomain.com in the above code with your actual domain name.

Redirect to www (htaccess redirect)

(1) First create a .htaccess file with code,it will redirect all request to www.domain.com.
(2)Place the .htaccess file into the root directory.
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
(3)Now finally REPLACE domain.com and www.newdomain.com with your actual domain name.

1 comment:

  1. Remove all the article that you copied from BLOGSPOTINFO otherwise i will complain in DMCA and your blog will be deleted in 2 days because of copyright violation.

    ReplyDelete