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.
  • 29 Users Found This Useful
Was this answer helpful?

Related Articles

Configuring the PHP Environment With php.ini

Problem: How do I change the PHP environment for my site with php.ini? Solution:   To...

PHP with FastCGI

Problem: What is FastCGI for PHP? Solution: FastCGI for PHP makes all your PHP applications...

Upload_Max_Filesize

Problem: How do I change my upload_max_filesize? Solution: Summary Locate the php.ini...

Cron Jobs with PHP Files

How do I run a php file using Cron jobs?   From the cPanel, click the Cron Jobs icon and enter...

Basic Site Security Checklist

Remove malicious files and/or files you are not familiar with. While many PHP applications...