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.
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.