Search
Recommended Sites
Related Links

 





   

Informative Articles

Accessible Web?
The web started out its life as a collection of simple HTML pages which were, by nature, accessible. Many people with disabilities latched onto the web as a revolutionary new way for them to communicate. However, since the commercialisation and...

Keywords are the "KEY" to a Profitable Web Site
The only activity that should preface keyword research is the brainstorming you do to come up with list of potential themes for your web site. Think about things that you find interesting, are passionate about or that leverage your skills. Once...

Learn HTML Through Theft & Mutilation
Anyone serious about having a website needs to know something about HTML, the computer code of websites. HTML is a simple language - although some native speakers would argue that so is Swahili - it is made up of characters from your keyboard....

Web Accessibility and Your Business
One of the things I find I'm most often fighting with my peers and competitors is the need for your website to be accessible. An Accessible website is a website that caters to the needs of disabled individuals and people using alternative web...

Website Theft - Part 2 of 3 ~ How do I know if my website material has been stolen and what do I do if it has?
(Please note that some of the information included in this article has been quoted from various locations while other information is simply my personal opinion and you will probably feel my passion in my words.) In the first instalment in our...

 
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/