Redirection – HTML Redirect or Web Page Redirect

Recommended Videos

How to Forward or Redirect URL to Another Website
How to Forward or Redirect URL to Another Website
How to redirect a webpage using meta tag in HTML
How to redirect a webpage using meta tag in HTML
Create a Redirect Link in HTML
Create a Redirect Link in HTML
JavaScript - Page Redirect
JavaScript - Page Redirect
JavaScript Redirect - An Easy Way to Redirect URLs
JavaScript Redirect - An Easy Way to Redirect URLs

Do you want to know how to redirect an html page? Redirection is the technique of redirecting a web page URL to another.HTML Page redirection can be accomplished in several ways.This article will detail a few ways to accomplish a Web Page Redirect.

HTTP Redirect (HTML Redirect using meta http-equiv):

Though this is one of the most easiest ways to accomplish an HTML redirect, it isn’t the best way to redirect a web page.All you need to do is add a meta http-equiv tag to the head section of your HTML page. For example, adding the following code to the head section of html page will redirect it to “another-page.html” in 5 seconds.

<meta http-equiv="REFRESH" content="5;url=http://www.another-domain.com/another-page.html">

In the above tag, the number preceding the url “http://www.another-domain.com/another-page.html” ( 10 in this case), tells the browser to wait for so many seconds before redirecting to the new url – http://www.another-domain.com/another-page.html. You could set this to 0 to do an instantaneous page redirect.

Javascript Redirection:

You can also redirect a page to another page using a simple javascript. To create a JavaScript redirect, place the following code between the head tags of your HTML page.You may replace the URL – http://www.this-domain.com/newpage.html, with the URL that you want to redirect to.

<script type="text/javascript">
<!--
window.location = "http://www.this-domain.com/newpage.html"
//-->
</script>

However the big disadvantage of a javascript redirect is not all users may turn on javascript in their browsers.Thus, if javascript is turned off, this redirection technique may not work.

.htaccess redirect:

Another way (a better method) to accomplish an HTML redirect is by using a .htaccess file. However this will work only on an apache server and not on a windows server. However, you can check this article on how to create a 301 redirect on Microsoft IIS server.

  • Create a file on the root directory of your website and name it “.htaccess”. (create it in the root directory only if a .htaccess file does not exist already)
  • Open the .htaccess file using notepad or what ever text editor that you prefer.
  • Add the redirect command to the .htaccess file, save it and then upload it to your web server

Adding the following to the .htaccess file of the server in which the site (domain) is hosted, will redirect thispage.html to newpage.html in the same domain, say, www.this-domain.com.

Redirect 301 /thispage.html http://www.this-domain.com/newpage.html

You could even redirect thispage.html to a new page on another domain as follows:

Redirect 301 /thispage.html http://www.another-domain.com/newpage.html

Note that in the above examples, you should not add “http://www” to the first part of the statement (i.e. /thispage.html). You should only mention the path from the top level of your site to the page. Also ensure that you leave a single space between the two elements.

If you want to redirect the entire traffic on the current site to the index page of the new site (www.another-domain.com), add the following code to the .htaccess file of the current site:

Redirect 301 / http://www.another-domain.com/

The above are three different simple ways to accomplish a Page Redirect, though the .htaccess redirection is preferable over other methods explained here. However, note the example provided above for a .htaccess redirect is very basic.You could even accomplish more powerful web page redirection using Mod_Rewrite, which will be explained in detail, in another article.

Leave a Reply

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

*