megaarticlepicks.com megaarticlepicks.com megaarticlepicks.com
   Home Page -> About Us -> Security & Privacy -> Terms of Use -> Add Url -> Add Your Article
Search:   

 

Software & Networking

 

Finance & Investment

 

Recreation

 

Medicine & Treatment

 

Self Help

 

Relationship & Lifestyle

 

Society & Communities

 

Eating & Drinking

 

Realty & Property

 

Teens & Children

 

Technology & Science

 

Health & Hygiene

 

Outdoor & Sports

 

Business & Companies

 

Shopping & Auction

 

Tour & Travel

 

Education & Reference

 

Art & Culture

 

Careers & Employment

 

Home & Garden

 

Policies & Law

 

News & Events

 

Games & Play

 

Automobiles

 

  Home Page » Software & Networking » Web Design & Development
   
 

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:

<?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

<meta http-equiv="Refresh" content="[time]; URL=[some-url]">

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,

<meta 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

<script language=javascript> setTimeout("location.href='[some-url]'", [time]); </script>

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.

Author: Sanjib Ahmad
 
Author Bio:

Sanjib Ahmad

Sanjib Ahmad is a chief executive, programmer, graphics designer, musician and an author. He is currently dwelving on a new area of expertise.

 
 
 

Related Articles

 
Organize Your Adwords Account to Get More Visitors, Lower Your Cost Per Click and Increase ROI
 
How Do I Improve My Web Site Conversion Rate? Part 1
 
Affiliate Opportunity: Blogs Are All You Need
 
Kansas City Computer Repair: I Can't Get To My Banking Pages Anymore
 
MS Outlook based CRM Software to Manage Your Small Business Sales, Marketing & Customer Service
 
Sheep Spend and Lose, Leaders Make Money
 
Do-It-Yourself Search Engine Marketing Versus Search Engine Marketing Services
 
The New Age Advertising Method
 
Who Benefits From Using a Professional to Develop Good IT User Documentation?
 
Free $50 yahoo search marketing credit
 
 
 
   Home Page -> Security & Privacy -> Terms of Use
Copyright © 2008 www.megaarticlepicks.com