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


How To Get Your Customers To Trust Your Website

Research reveals three important facts:1) The Internet is one of... Read More

Do This One Thing to Create a Powerful Product-Selling Web Site

Spend time planning your Web site. Before you design a... Read More

Newsletter Management Using PHP w/o mySQL for Beginners

Let's begin by setting some limits. If you're like me,... Read More

Growing Your Meetings In CyberSpace

As increasing numbers of people search for information on the... Read More

Top 5 Reasons to Track Your Website Traffic

#5 User Satisfaction: Learn what your visitors and site users... Read More

My Yahoo Search - Beyond Bookmarks

Yahoo has long offered email, an online calendar, notes, bookmarks,... Read More

Is Your Website Innovative? Increase Your Business Over Night!

While studying online for IT investment opportunities, I found that... Read More

The Topic Of Your Website

The first thing you will have to deal building your... Read More

Ever Wondered What Challenges Other People With Their Web Site?

Have you ever wondered what challenges are faced by other... Read More

Learn What 98% of Targeted Visitors Do On Your Website

Getting a Targeted Visitor to a website is a waste... Read More

Website Content & Usability

Writing for the web is totally different to writing for... Read More

Does Your Business Really Need A Website?

Website, website, website, everyone says you need one. But do... Read More

How to Promote Your Law Firm Website On the Internet for Maximum Profit

Making maximum profit from your law firm website is important,... Read More

Beautiful Web Sites Seldom Make More Sales

Designing an E-commerce Web site is not as simple as... Read More

Effectively Using Robots Meta Tags

The "robots" meta tag, when used properly, will tell the... Read More

Autoresponders Make You Look Like A Pro

People like to get immediate responses to requests. Autoresponders are... Read More

Entangled in the World Wide Web

I am just a learner who likes to delve in... Read More

Why You Need a Website

You hear a great deal about the Internet these days... Read More

How Your Own Website Helps Your Small Business Grow

What do you mean, you don't have a website for... Read More

How to Handle Web Surfers Who Disabled JavaScript

There are hundreds of millions of Web surfers today. Each... Read More

Email Addresses in Web Pages

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

Writing Effective ALT Text For Images

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

A Website Is Not Enough

Your ObjectiveYour small business needs an appealing and professional website... Read More

Non-Profits: Successful Online Strategies

More and more non-profit organizations are developing websites to help... Read More

Five Essential Questions to Answer Before Creating Your First (or second...or third) Website

Right after the thought, "I need a website," people usually... Read More

4 Rock Solid Reasons For Building Your Own Website

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

Why Your Brick-and-Mortar Biz Needs A Website

The internet has taken over our lives with a vengeance,... Read More

7 Profit Producing Reasons Why Every Successful Service Professional Needs A Web Presence

Your business website is a critical aspect of being able... Read More

Improve Web Sales Figures Forever And Ever Amen!

"How do I improve web site sales figures?" The CEO... Read More

The Birth of a Professional Web Site

The Internet has opened a whole New World of opportunity... Read More

How To Convert More Sales On Your Website

One of the biggest mistakes that most online retailers make... Read More

Increase Hits to Help Increase Your Business

In this day and age most businesses consider having their... Read More

The Importance of Website Stats to You

One of the best tools you have as a webmaster... Read More