Search
Recommended Sites
Related Links






Valid XHTML 1.0 Transitional

Valid CSS!
   

Informative Articles

Choosing The Right Blog-Tools
Choosing The Right Blog-Tools Bloggers are constantly discovering new ways to express their ideas through new markup. There are bloggers who are using the latest state-of-the-art "visual" web design programs, but few others consider using HTML...

Internet Basics: Plug-ins Are Like Popeye's Spinach
Ever watch Popeye the Sailor Man cartoons? All on his own, Popeye could do quite a lot. He could walk and talk and sing and smoke his pipe. But when it came time to deal with his nemesis, Brutus, Popeye just wasn't up to the task. Not until he ate...

Sins of The Internet: Mousetraps (and worse)
One common unethical web technique is called mouse trapping, which is often used in conjunction with another highly immoral practice called page jacking. In it's simplest form, mouse trapping merely consists of redefining the back function so...

Validating Numerical Input with JavaScript
What? Make a mistake entering data? Who me? NO WAY! Right. Every form of data input by a user should be validated in some form or fashion. If you get clean data in, you won't get garbage out. This tutorial is going to explain how to validate ...

Why You Should Use Turnkey Websites To Jumpstart Your Ecommerce Activity
Most people looking to do business online have heard of turnkey websites. They seem to be a one stop solution to getting an online business going without all the usual hassles associated with an online startup. Take a look thought the business &...

 
PHP Redirect

A PHP Redirect automatically transfers a web user from one URL to another. For example, typing foo.com in the browser automatically transfers the user to another URL bar.com.

The PHP Redirect command:

<?php
header("location: [some-url]");
?>

Replace [some-url] with the URL where you want the redirection to take place.

For example,

header("location: ./version2/index.html");
=>redirect to "index.html" page in subfolder called "version2"

header("location: http://www.yahoo.com");
=>redirect to a website called yahoo.com

If PHP is not available, it's also possible to use other redirects:

* HTTP Redirects
<meta http-equiv="Refresh" content="[time]; URL=[some-url]">

Replace [time] with seconds. This will pause the browser for the specified number of seconds. Replace [some-url] with the target URL you want to redirect.

For example,
<meta http-equiv="Refresh" content="5; URL=http://www.yahoo.com">;

The above HTTP based redirect needs to be in the <header></header> region of the HTML code.

* JavaScript Redirects

<script language=javascript>
setTimeout("location.href='[some-url]'", [time]);
</script>

Replace [time] with milliseconds. This will pause the browser for the specified number of seconds. Replace [some-url] with the target URL you want to redirect.

For example,
setTimeout("location.href='http://www.yahoo.com'", 5000);

The above JavaScript based redirect can be either in the <header></header> or <body></body> region of the HTML code.

Usually a PHP redirect is much more reliable than other form of redirects like HTTP redirect or JavaScript based redirects. For example a JavaScript redirect may not work if a user's browser settings has JavaScript turned off.

The reason why PHP redirects will work no matter what settings users have on their browser is because PHP is server side script. It will not depend on browser settings that may affect JavaScript which is parsed on the client-side/user-side.

About the Author
Sanjib Ahmad, Freelance Writer and Product Consultant for Business.Marc8.com - Best Selling Business Books. You are free to use this article in its entirety as long as you leave all links in place, do not modify the content, and include the resource box listed above.

Sign up for PayPal and start accepting credit card payments instantly.