How to Redirect Web Page using HTML or PHP?

January 22nd, 2010

There are many times when you would like to redirect one particular page on your website to some other page or to a different url altogether. There is a very simple way to accomplish this.

Using HTML / PHP redirect

If all your pages are HTML pages, then HTML redirect would be the best option for you. You can either create a new file and place the script in it or you can use your existing .html or .htm file and add the code to it.

Place the following HTML redirect code between the and tags of your HTML code.

<meta HTTP-EQUIV="REFRESH" content="0; url="> 

The above HTML redirect code will redirect your visitors to another web page instantly. The content=”0; may be changed to the number of seconds you want the browser to wait before redirecting.

However if you wish to redirect a PHP file, then the below code would be the best option for you. Make sure that you just have the below code on the file and nothing above it. This code should be the first thing the server reads.

<?php header( 'Location:' ) ;?>

Note: You would need to change the to your domain name.

Related article:
1. Redirect Main Domain to Sub Domain using .htaccess

Leave A Comment