Search
Recommended Sites
Related Links






Valid XHTML 1.0 Transitional

Valid CSS!
   

Informative Articles

Awards Programs: Judging Sites
Okay, so you've taken the plunge and created your awards program. Your criteria are defined and well written, your purpose is understood and you've promoted the heck out of your program. Now you've started getting applications - and the real work...

Good News / Bad News of Computer Security from a Keen Non-Techie.
First for the Bad News: There are many risks attached to connecting to the Internet. The only way to keep one hundred percent safe is by not connecting! But who wants to do that especially if one's in business? It is a fact that when you...

Interactive Content - Blogs, Forums and Feedback - what does your web site need?
Both search engines and customers love fresh, updated information. Nothing promotes a business online better than staying in touch with prospects. The more interactive the continued contact, the better the relationship that is built with a potential...

Make a Search Engine For Your Website With PHP
This hands on PHP Programming article provides the knowledge necessary to design and develop a search engine for your website using PHP version 4.0 and above. Making a search engine for your website with PHP is really easy and provides...

Pass the Mystery Meat: Learning from "Web Pages that Suck"
Though I learned much at Shakespeare's knee, the two years I worked for the undergraduate literary magazine at the University of Utah were almost as valuable. Every night, I took home fat manila folders full of poetry and fiction that were horribly...

 
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.