How To Create A PHP Header Redirect

Table of Contents

PHP Redirection

 

 

Redirecting to another website

To setup a simple redirect in PHP you will need to create a header() function. Simply create a index.php file in the location you want to redirect from with the following line of code:

< ?php header(“Location: https://URL-YOU-WANT-TO-REDIRECT-TOO/”); ?>

This will now redirect to the website location you typed.

 


Redirecting to another page or directory

You can also create a file that links internally on your file manager.

<?php header(“Location: anotherDirectory/anotherFile.php”); ?>

When linking to an internal file it doesn’t have to match a .php extension, It can be the following programs python, HTML, php, perl, cgi and compiled cgi programs.

 

Need FREE Website Hosting?

CONORBRADLEY.CO.UK

Slider
Next How to Create the WordPress .htaccess File