For implementation of URL redirection below are the methods:
IIS Redirect
If the virtual directory that is mapped to the following Web site:http://yourcompany/Scripts
is configured to be redirected to the following exact URL:
http://yourcompnay/NewScripts$S$Q
A new request for the following URL:
http://yourcompany/Scripts/File.asp?var1=5&var2=6
Would be redirected automatically to the following URL:
http://yourcompany/NewScripts/File.asp?var1=5&var2=6
Cold Fusion 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)
Create a .htaccess file with the below code, the .htaccess file should be in the root directory where you index file is placed. Then, type this codes:Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
You are expected to replace www.thenewdomain.com in the above code with your actual domain name.For redirection I would like to add that you contact every back linking site to modify their back link to point your new website.
Important note: The .htaccess redirection can be applied on Linux machine having Apache Mod- Rewrite module enabled.
Redirect to WWW (.htaccess Redirect)
Please create an .htaccess file with the code shown below. The .htaccess file should be placed in the root directory where your index file is placed.Options +FollowSymlinks RewriteEngine on rewritecond %{http_host} ^yourdomain.com [nc] rewriterule ^(.*)$ http://www.yourdomain.com/$1 [r=301,nc]
You are expected to replace yourdomain.com and www.thenewdomain.com with your actual domain name.
Important note: The .htaccess redirection can be applied on Linux machine having Apache Mod-Rewrite moduled enabled.
The code to redirect youcompany.com to www.yourcompany.com would be as follows.
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www\.yourcompany\.com [NC] RewriteRule ^(.*)$ http://www.yourcompany.com/$1 [L,R=301] </IfModule>
The code to redirect www.yourcomapny.com to yourcompany.com would be as follows.
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^yourcompany\.com [NC] RewriteRule ^(.*)$ http://yourcompnay.com/$1 [L,R=301] </IfModule>
How to Redirect Using HTML
Use below code:<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Your Page Title</title> <meta http-equiv="REFRESH" content="0;url=http://www.the-domain-you-want-to-redirect-to.com"></HEAD> <BODY> Optional page text here. </BODY> </HTML>
discuss this topic to forum
