Featured Tutorials

photoshop tutorials, gradient filter, photo effects, brand image,gradient mapping,gradients in photoshop,gradient colours,photo gradients,gradient photo,gradient filter,photoshop filters Gradient Mapping

Gradient Mapping

How to transform a standard photograph for use with a specific colour scheme or brand imag..

software articles, free software, converting, encoding, downloads,avi to flv,create flv,flash video converter,mov to flv,mov to avi,avi to mov,avi conversion,mov conversion,sorenson FREE Video Encoding/Converting Software

FREE Video Encoding/Converting Software

A great list of freeley available video encoding/converting software for converting AVI to..

web design articles, html, css, php, asp, include function,include in php,include in asp,including files,html include,asp include,php include,how to design websites,websites tutorial Building your website with includes

Building your website with includes

Using server side includes to design and code your web site allows you to keep your develo..

where to submit,tutorial sites,articles,directories,submission,site promotion, submit artilcles,photoshop tutorial sites,flash tutorial sites,promote tutorials,best tutorial sites Build Traffic Mountains, great places to submit your Tutorials and Articles

Build Traffic Mountains, great places to submit your Tutorials and Articles

A list of great sites to submit your tutorials and articles that actually bring traffic to..

adobe,photoshop,panorama,panoramic,images,photos,photo merge,merging,how to,automatic,automatically Panoramic images the easy way with Photoshop PhotoMerge

Panoramic images the easy way with Photoshop PhotoMerge

Creating Panoramic images from your photos is easier than you think, when you know how. So..

Featured Videos

This tutorial will teach you some of the basics of the third part..

Sorenson Squeeze is a great piece fo software that has saved my a..

A very easy photoshop tutorial that shows you how to create a stu..

I never realised how easy it can be to create some really amazing..

A useful tutorial for creating an Ethernet or Patch Cable for net..

Auto Redirect To An Alternative Webpage Or Site

Sometimes it is necessary to redirect traffic to a new webpage or a different site altogether if you are using a new domain name to promote your site. There are a number of ways of approaching this, depending on whether search engine optimization is important to you.

Here Iím going to discuss a few of them. Itís not an exhaustive list by any means but shows some of the main ways of doing it.

Some of the methods provide an immediate redirect, others a short delay. It is important to be aware that in some cases, the search engines donít like you to redirect that way and may mark you down as a result.

Method 1 Ė Meta Refresh Tag

This method is ideal for pure HTML sites as there is no scripting involved, however search engines can detect the redirection. It is generally recommended that you allow a short delay of maybe 5 seconds or so for the redirection, so itís best if you show a message on the page explaining to the user that this URL is no longer valid and they will shortly be redirected to the new page.

Add the following code to the <head> section of your HTML page, replacing the [new URL] with the page or URL you want to redirect to. The number immediately preceding the URL is the delay in seconds before the redirection occurs.

<head>
<meta http-equiv="refresh" content="5;url=[new URL]">
</head>

For example to redirect to a page called mynewpage.html in 10 seconds you would add:

<meta http-equiv="refresh" content="10;url=mynewpage.html">

To redirect to the www.thecodefish.com website in 5 seconds you would add:

<meta http-equiv="refresh" content="5;url=http://www.thecodefish.com">

If you donít want a delay, set the value to 0 (zero). This is generally not recommended though as your favourite search engine may penalise you.

Method 2 - Using The Classic ASP or ASP.NET (c# or VB.NET) Response Object

Using ASP to control the redirect means that the redirection is placed in a server side statement and is processed before the rest of the page is rendered to the browser. In this case, itís pointless putting anything for the user to read in the HTML as the browser wonít see it. This means really that the only point of doing it this way is as an alternative to setting the browser redirect delay to 0 as in example 1, which as mentioned has some limitations in its appeal.

If you want to go ahead anyway, add the following code to the top of the page:

VB or VB.NET:
<% response.redirect(ďmyNewURLĒ) %>

C#
<% response.redirect[ďmyNewURLĒ] %>

So to take the main example again, if you want to redirect to thecodefish site, you would add:

<% response.redirect(ďhttp://www.thecodefish.comĒ) %>

Note if youíre using c# replace the () brackets with [] square brackets in the example.

Method 3 - Using Javascript

There are 3 main ways of achieving a redirect using Javascript, that Iím aware of anyway.

  1. Using a location.replace
  2. Submitting a form
  3. Clicking a link

In each case the submission is automated by the script but as far as Iím aware search engines donít detect the process, not yet anyway.

The main downside to using script is that it wonít work with browsers that donít support Javascript, or if users have turned it off.

Whilst you donít have to, itís probably best if you place the script within the <head> section of your page.

Using Location.Replace

<head>
<script language="javascript">
<!--
location.replace("[myNewPage]")
//-->
</script>
</head>

Replace [myNewPage] with either a page name like newpage.html or a URL like http://www.thecodefish.com For example:

<head>
<script language="javascript">
<!--
location.replace("http://www.thecodefish.com")
//-->
</script>
</head>

An additional advantage of this method is that the new page replaces the current page in the browser history so the back button will send the user to the new page rather than the redirector page.

Using a Form Submit

In this case, the Javascript submits the form to the new page, thereís no need for you to click a button. Search engines donít generally submit forms for you, and this should look like a normal page to them.

<head>
<script language="javascript">
<!ó
document. redirectForm.submit()
//-->
</script>
</head>
<body>
<form name="redirectForm" action="[myNewPage]" method="get">
</form>

Again, replace [myNewPage] with either a page name like newpage.html or a URL like http://www.thecodefish.com The comment tags help to hide the script from browsers that donít support Javascript.

Clicking A Link Programmatically

Thereís a few different ways to achieve this but this is a simple one. The problem with this method is that not all browsers support the functionality. In reality, if youíre going to use script youíre better off using one of the previous two methods.

<body onload="document.getElementById('AutoRedirect').click();">
<a id="AutoRedirect" href="http://www.thecodefish.com">Redirection Link</a>
</body>

One Final Thing

You might want to tell your favourite search engine that you no longer want them to index this page.

If thatís the case add the following to the head section of the page:

<meta name="Robots" content="NOINDEX">

Summary

Deciding on the best method to choose is down to you. If you think a short delay is acceptable use method 1, if not you may be better off with one of the javascript methods. Donít forget though that scripting can be disabled or may not available on some browsers, so maybe a combination approach would work best.

I hope youíve found this interesting and informative.

About the author

Paul Sheperia is a software developer and technology consultant, the founder of Applaud Web Solutions, and joint owner of the popular tutorial sites wipeout44.com and thecodefish.com

© 2009 Wipeout44.com

 

More Web Design...

Other Content...

 Subscribe to our feed

Send to a friend