Search
Recommended Sites
Related Links






Valid XHTML 1.0 Transitional

Valid CSS!
   

Informative Articles

An Easy Way to Choose Attractive Color Combinations
An Easy Way to Choose Attractive Color Combinations by Sunil Tanna of Answers 2000 http://www.ans2000.com/ ----------------------------------------------------------------- Publication Terms And Conditions: Answers 2000 Limited grants you a free...

CLEAN UP THAT CODE!
How do you write your code so that it shows up on all or most browsers the way you want it to look? By understanding which browsers support which tags, and using a validation service to check your code. There are different tags that sometimes do...

Do you want Better Search Results – Read Art of the Content Site
After reading the newest ebook published by Nathan Anderson, I was floored at how it easy it was to generate great search engine results without paying a guru an outrageous sum of money to do so. The search engines are accessible to everyone...

Don't Let Your HTML Email Newsletter Break!
Don't Let Your HTML Email Newsletter Break! By Jessica Albon Copyright 2003, The Write Exposure Offering your email newsletter in HTML frequently results in higher subscribe rates, greater reader recognition and impressive ROI. That is, if they're...

How to Set up Your Own Personal Website, without Spending Any Money
It has been my dream, right from childhood, to establish a great site, without spending any money. So I searched the web, for free domain names, free web hosting and free websites. I would like to share the results of my search with you. I have...

 
PHP Redirect

"Usually a PHP redirect is much more reliable than other form of redirects like HTTP redirect or JavaScript based redirects"

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


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,
< m e t a http-equiv="Refresh" content="5; URL=http://www.yahoo.com" >

The above HTTP based redirect needs to be in the region of the HTML code.


* JavaScript Redirects

< s c r i p t language=javascript>
setTimeout("location.href='[some-url]'", [time]);


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,
set Timeout("location.href='http://www.yahoo.com'", 5000);

The above JavaScript based redirect can be either in the or 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 (http://business.marc8.com/). 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.

Copyright Sanjib Ahmad - http://business.marc8.com/


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