All in one redirect scripting

HTML redirect:

For most of the webmaster, they will prefer 301 Redirect. With HTML redirect with HTML, I will suggest canonical type.

You may use the following script from the HTML with canonical redirection.

HTML:
  1. ‹link rel="canonical" href="http://www.mickgenie.com/blog/" /›

htaccess with mod_rewrite redirect:

If you are using Apache or Mod_Rewrite enabled Web services, htaccess with mod_rewrite redirect is very useful, you may use the following script to perform your redirection.

CODE:
  1. RewriteEngine On
  2. RewriteCond %{HTTP_HOST} ^mickgenie.com
  3. RewriteRule (.*) http://www.mickgenie.com/$1 [R=301,L]

ColdFusion Redirect:

Sample code for Cold Fusion.

CODE:
  1. ‹cfheader name="Location" value="http://www.mickgenie.com/"

PHP Redirect:

Sample code for PHP.

PHP:
  1. ‹?php
  2. header("location:http://www.mickgenie.com");
  3. ?›

ASP Redirect:

Sample Code for ASP.

ASP:
  1. ‹%@ Language=VBScript %›
  2. ‹%
  3. Response.Status="301 Moved Permanently"
  4. Response.AddHeader "Location", "http://www.mickgenie.com/"
  5. %›

ASP.Net Redirect:

Sample Code for ASP.Net.

ASP:
  1. ‹script runat="server"
  2. private void Page_Load(object sender, System.EventArgs e)
  3. {
  4. Response.AddHeader("Location","http://www.mickgenie.com/");
  5. }
  6. ‹/script›

Java Redirect:

Sample Code for Java.

JAVA:
  1. ‹%
  2. response.setHeader( "Location", "http://www.mickgenie.com/" );
  3. response.setHeader( "Connection", "close" );
  4. %›

Perl & CGI redirect:

Sample Code for Perl & CGI.

PERL:
  1. $q = new CGI;
  2. print $q-› redirect(" http://www.mickgenie.com/ ");

Ruby & Ruby on Rails Redirect:

Sample code for Ruby & Ruby on Rails.

RUBY:
  1. head :moved_permanently, :location =› "http://www.mickgenie.com/

Popularity: 4%

Related posts:

  1. How to block a country range IPs?
This entry was posted in Microsoft IIS, PHP, Ruby on Rails and tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.
blog comments powered by Disqus