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:

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,

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

* JavaScript Redirects

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, setTimeout("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 http://www.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.

In The News:


pen paper and inkwell


cat break through


Track Your Visitors, Using PHP

There are many different traffic analysis tools, ranging from simple... Read More

Better Web Site ROI: Efficient Online Business with SEO, PPC, Split Testing, and Forums

If you're looking for better web site ROI, chances are,... Read More

Learn to Build a Better Online Business Website Using Keywords and Content

Are you aware that 90% of the websites on the... Read More

Whats Your Business Online Attitude?

This article was prompted by some customer support work I... Read More

How To Get Profits From Your 404 Page Not Found File

"'Page Not Found' on this Server. Check the URL and... Read More

How to Get a Better Web Site ROI

Better Web Site ROIHow to increase your business profitability by... Read More

Using Psychology Easily on Your Website to Make More Sales!

Psychology is a long word which everyone thinks, "no, that's... Read More

Wheres Your Focus, Money or Customer?

Is your website Really useful?I had a 'rep' in yesterday... Read More

Let Your Customers Redesign Your Website!

When you purchase a new item from a Yahoo! Store,... Read More

Email Addresses in Web Pages

You want to give your site's visitors a way to... Read More

Linking Out is Good

Many websites I come across don't have a single link... Read More

Five Reasons You Have to Stop Your Web Site

That's right. Your method, behavior and strategy you are now... Read More

Writing Effective ALT Text For Images

Anyone who knows anything about web accessibility knows that images... Read More

The Secret Benefit Of Accessibility: Part 2 - A Higher Search Engine Ranking

An additional benefit of website accessibility is an improved performance... Read More

Do You Really Need A Website To Succeed

Rosalind wants to share her inspirational poetry with a wider... Read More

How to Build a Database Driven Web Site

If you ever want to create a state directory, article... Read More

4 Rock Solid Reasons For Building Your Own Website

What is the point of having a website, you may... Read More

Why to Have a Website for Your Company

After having decided to start a business, the next thing... Read More

Things to Consider Before Starting a Website

In the time that I have been using the Internet,... Read More

Setting Up Your First Website

Q. Hey, Cathy: I'm just setting up a website. What... Read More

Marketing Your Business Online

As a business you can't afford to ignore the Internet... Read More

Why Is No-one Buying From My Website?

Are you, like many other website owners, frustrated at the... Read More

A Beginners Guide to Server Side Includes

An Introduction to Server Side IncludesBeginner? That's OK!While much has... Read More

What is The Google Toolbar?

No matter what browser you may want to use, you... Read More

Study Your Sites Performance Via Hit Tracking

Knowledge is power.And undoubtedly, it is the key to making... Read More

Benefits Of Making Your Website Accessible To Disabled Users ? Part 2: The Business Case

The Disability Discrimination Act states that service providers must not... Read More

HTML Editors 101 - Smaller Is Better

SiteSpinnerSiteSpinner is a user-friendly web site development tool that includes... Read More

Stop Losing Precious Web Site Traffic to the Dreaded World Wide Web Black Hole

You work hard to build traffic to your web page.... Read More

Make Your Own Brand!

There are millions and millions of websites on the Internet.... Read More

The Most Important Aspect of Writing Web Copy

There is an ongoing debate about web copy. Some say... Read More

Your Website Reflects Your Business

Some left shoes are in isle 5, while the right... Read More

The Dos and Donts of Launching a Small Business Website

Launching a new small business website is often a long... Read More

Six Basic Reasons Why Visitors Stay On Your Web Site

1. The first page appears quickly.It's a good way to... Read More