Search
Recommended Sites
Related Links






   

Informative Articles

14 Ways to Add Content to Your Web Site
When I surf the Net, I often see web sites filled with beautiful graphics that strive to capture my attention. Well, they do so for an instant, however I click away when I don't immediately find relevant content. The content you add to your web site...

A must-know about computer and internet glossary
Computer-related things tend to have a language all their own. While you do not need to know all of it, there are many confusing words and phrases that you are going to come across sooner or later. Bandwidth. Bandwidth is the amount of data...

Developing a Login System with PHP and MySQL
Used with the author's permission. This article is written by daBoss. daBoss is the Webmaster of Designer Banners . daBoss can be contacted at sales (at) designerbanners (dot) com. Developing a Login System with PHP and MySQL Most interactive...

How to Build a Basic CSS Layout
Designing without tables by using CSS layouts is fast becoming the new standard on the Web because of the benefits mentioned in my previous article. Web browsers used these days are now able to render web pages proficiently. In this article I will...

How To Select A Good Website Hosting Company
I constantly encounter people that want me to design or update a website for them, and they are already signed up with a hosting company. The only problem is that many of these people should never have signed up with that particular hosting company....

 
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.