How to Correctly Redirect Visitors: When website is moved to a new location

A number of techniques are available for redirecting visitors when the website is move to a new location. You can choose any method as per your convenience and requirements. Some of these techniques are described below. Just make sure that you are using the right code.

1. Browser side redirection using JavaScript

JavaScript is the most popular scripting language used for redirecting web pages. Since it makes the redirection conditioned, so this technique is quite useful. You can cloak the content by redirecting a page without a condition. The advantage of cloaking is that the users will be swiftly redirected and at the same time, the web page will still be interpreted by the search engines because they can penetrate through the JavaScript. The meta-refresh redirection waits for the page to load first. However, JavaScript allows you to place the code in the header because of which browser won’t have to wait for the page to load first and redirection is executed instantaneously and that is why JavaScript redirection is faster than meta-fresh redirection. The modern search engines are optimized to look for redirection in JavaScript, therefore, it is up to you to either encrypt the script or load it from a remote file.
/* example */
window.location = "http://www.google.com/";

2. Browser side redirection using HTML

HTML can also be used for redirecting a page. You can redirect a page immediately or after a period of time using the meta-refresh tag. However, this method has one disadvantage associated with it: pages that use page redirection technique are penalized with short delays by some search engines. It happens because it could appear as a cloaking attempt. But this technique can be useful in a different way. Using this technique you can redirect the visitors of your web page to a different site of yours or directly to a sponsor’s page, with your referral code after 350 second. The idea behind this approach is that if a surfer has opened your site along with a number of other web pages in a stack of windows and tabs and then he starts closing all the tabs one by one, he will certainly stop at the new page and look at it.
/* example */

window.location = "http://www.google.com/";

3. Browser side redirection using Flash

The redirection technique will be quite simple for you if you are comfortable working with flash. You can simply make your own flash movie with one frame, this movie can be used to create an immediate redirect. You will be done with the redirection once you have pasted the relevant code into the actionscript. You can also use this technique if you don’t want to redirect instantaneously but after a period of time. All you need to do is to make a movie of the appropriate time duration and then paste the code for it into the actionscript pane of the last frame.
/* example */
var url:String = "http://www.google.com"
var urlRequest:URLRequest = new URLRequest(url);
navigateToURL(urlRequest, "_blank");

4. Server side page redirection using PHP

If you want to redirect to a different page depending on the outcome of a script,then this technique can be useful. With the help of appropriate skills and this technique, you can redirect to books review on a Sunday, political news on Monday, a joke page on Tuesday and so on. However, one thing that should always be kept in mind is that any text or HTML should be sent to the browser only after calling the function. If the function is called after the redirect, then the redirection will fail showing an error message.
/* example */
header("Location: http://domain.com/");

5. Hidden Browser side redirection using Iframe and JavaScript


If you belong to the category of those people who are too wary of search engines finding their page to be redirected, then this method is certainly for you. You just have to put an Iframe in the page which you want to redirect and then put the url of the page you wish to redirect to in the source attribute of the Iframe. The browser loads the new page into the Iframe if you have followed the above procedure. Then the page is executed in framebreaker and in the place of the page that was originally loading, new page is displayed. This JavaScript technique can be be used for quickly redirecting a page.

6. Server side redirection on Unix servers using .htaccess 301

A page which is properly supported by search engines can be redirected to a new page only by using Result Code 301. This technique is known as a permanent redirect. The advantage of this technique is that Google not only transfers all the traffic but also any page rank to the new page. The instructions for the server on your site are contained in .htaccess files which are simple text files. These files can be included in two different ways, either one such file can be placed in every directory where it is needed or a single file can be used for the entire site by placing it in the document root directory. You can simply add new redirects to the top of the file in case you already have a .htaccess file in your directory.

/* example */
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

7. Page redirection from any point in a PHP script

This is another popular technique that serves the function of redirecting visitors using PHP script. This technique gives you an option of redirecting your page at any given interval. In case you stumble upon the awkward header which the script may produce sporadically, then this technique can be utilized.
/* example */
header("Location: http://domain.com/");
exit;

8. Server side redirection on windows servers using ASP and ASP.net

If you are using ASP or ASP.net on windows servers and your old page is an ASP.net page, you can change it’s content to perform a redirection in the following way.
/* example */
/* ASP */
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.new-url.com/"

/* ASP.NET */
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.com");
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>