HostMonster Web Hosting Help

PHP Redirect

Problem:

How do I redirect users to another page using PHP?

Solution:

Redirection in PHP can be done using the header() function. To setup a simple redirect, simply create an index.php file in the directory you wish to redirect from with the following content:
        < ?php header("Location: http://www.redirect.to.url.com/"); >
        
Where 'http://www.redirect.to.url.com/' is the URL you wish the users to be redirected too. This can also be a file, like so:
        <?php header("Location: anotherDirectory/anotherFile.php"); ?>
        
Files can be of anytime including but not limited to HTML, python, php, cgi, perl, and compiled cgi programs.
Knowledgebase Article 100,080 views bookmark tags: header php redirect redirects (updated 1791 days ago)


Was this resource helpful?

Did this resolve your issue?


Please add any other comments or suggestions about this content:





Recommended Help Content

Redirects allow you to make a specific web page redirect to another page and display the contents of that page. Learn how to setup a Permanent (301 or Termporary (302) redirects. (updated 1376 days ago)
Video "How-to" Tutorial 264,425 views tags: cpanel cpanelutilities domain forward redirect

The redirection of www.yourdomain.com/default.html or index.html to http://www.yourdomain.com/index.php?act=whatever redirects it to http://www.yourdomain.com/index.php%3fact=whatever In other words, (updated 577 days ago)
Knowledgebase Article 717,969 views tags: htaccess messing mod php redirect redirects rewrite variable variables

How do I create a redirect? (updated 154 days ago)
Knowledgebase Article 249,090 views tags: htaccess redirect redirects

Related Help Content

If suddenly when you go to your page, you get nothing on the page. You can still get HTML to display, just not PHP. To serve HTML pages to browsers, we don't associate the Apache processes with your 2 (updated 2167 days ago)
Knowledgebase Article 63,548 views tags: page php

How do I view the php information page? (updated 487 days ago)
Knowledgebase Article 73,986 views tags: php phpinfo

When creating a symlink to a php page, I get a 500 error. I am able to use symlinks to other files and folders fine. (updated 1909 days ago)
Knowledgebase Article 55,844 views tags: link php

How do I perform a URL redirect/rewrite using the .htaccess file? (updated 181 days ago)
Knowledgebase Article 711,020 views tags: htaccess redirect rewrite url

Why do scripted e-mails come from &lt; username@host###.HostMonster.com &gt; when I have specified otherwise? (updated 46 days ago)
Knowledgebase Article 219,232 views tags: email forms header php script scripted sendmail

PHP vs PHP single php.ini vs PHP with FastCGI (updated 1199 days ago)
Knowledgebase Article 148,562 views tags: configuration php server

This article will explain how to create and manage users on Dedicated or VPS servers. (updated 19 days ago)
Knowledgebase Article 313 views tags: dedi dedicated users vps

How do I display the Internet email header? (updated 516 days ago)
Knowledgebase Article 225,885 views tags: email header mail