Bluehost Web Hosting Help

How To Code a PHP Redirect - PHP Header Redirect

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 any type including but not limited to HTML, python, php, cgi, perl, and compiled cgi programs.
Knowledgebase Article 933,921 views bookmark tags: header location php redirect redirects


Was this resource helpful?

Did this resolve your issue?


Please add any other comments or suggestions about this content:





Recommended Help Content

Redirecting Web Page

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.

Redirects that do not work due to PHP variables

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,

How To Redirect A Website - How To Setup A 301 Or 302 Redirect

How do I create a redirect?

Related Help Content

PHP pages do not display

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

PHP information page

How do I view the php information page?

How To Redirect Rewrite Using The htaccess File - www to non-www

How do I perform a URL redirect/rewrite using the .htaccess file?

Executing PHP code within an HTML document

Executing php code within a HTML document

Scripted Emails Appear to Come from username at myserver

Why do scripted e-mails come from < username@box###.Bluehost.com > when I have specified otherwise?

How To Add Handlers To Change PHP Version - PHP Version Setup

This article will explain how to add a PHP handler to your .htaccess files. This is useful if you want to customize the version of PHP that runs your PHP files.

EPP Auth Code

I need an EPP authorization code to transfer my domain to another registrar.

Displaying Email Headers

How do I display the Internet email header?