How To Code a PHP 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: https://www.domain2redirect.com/”); ?>

This can also be a file, like:

           <?php header(“Location: someDirectory/someFile.php”); ?>

 

For more information check:

https://www.php.net/manual/en/function.header.php


demo

  • PHP
  • Includes: index.php

previous

Please check for future updates here or at my gitHub page.