123ArticleOnline Logo
Welcome to 123ArticleOnline.com!
ALL >> Computers >> View Article

Php Redirect

Profile Picture
By Author: Sanjib Ahmad
Total Articles: 7
Comment this article
Facebook ShareTwitter ShareGoogle+ ShareTwitter Share

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,


The above HTTP based redirect needs to be in the <header></header> 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 <header></header> or <body></body> 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 - Best Selling Business Books. 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.

Total Views: 164Word Count: 286See All articles From Author

Add Comment

Computers Articles

1. Drug Monitoring And Incubator Monitoring Support Reliable Conditions For Research Healthcare And Laboratory Environments
Author: Chris Miller

2. Desktop Rental Solutions For Events, Exhibitions, And Conferences
Author: Rashi

3. Point Of Sale Machine For Shops: How To Choose The Right One
Author: pbs

4. Master Data Management Vendors 2026: Spark Matrix™ Analysis By Qks Group
Author: Umangp

5. Ecommerce Web Development: Building An Online Store That Drives Sales And Growth
Author: scopycode

6. How To Do External Hard Drive Recovery
Author: Magic Data Recovery

7. The Process Of Flash Memory Card Recovery
Author: Magic Data Recovery

8. Spark Matrix™: Unified Endpoint Management (uem)
Author: Umangp

9. Selecting A Company For Network Security In Los Angeles
Author: Computer Networks L.A.

10. Your Best Choices For Computer Repair In Los Angeles
Author: Computer Networks L.A.

11. How To Build The Perfect Personalized Gaming Rig For Your Gaming Needs?
Author: Jack Williams

12. Mobile Workforce Trends Transform Modern Crm Strategies
Author: Larry Caretsky

13. Ai-powered Field Service Software Transforms Business Operations
Author: Larry Caretsky

14. Workforce Identity And Access Management Market Research: Trends, Vendors, And Future Outlook
Author: Umangp

15. Identity Fabric Market Research: Trends, Vendor Landscape, And Future Outlook
Author: Umangp

Login To Account
Login Email:
Password:
Forgot Password?
New User?
Sign Up Newsletter
Email Address: