Networking, Programming and Graphics - Tutorials
ONLINEHOWTO.net Tutorials Category

PHP forwarding

Type: Code Networking, Programming and Graphics - Tutorials
Networking, Programming and Graphics - Tutorials
Level: Beginner Networking, Programming and Graphics - Tutorials 
Networking, Programming and Graphics - Tutorials
Date: 2007-Apr-12
Networking, Programming and Graphics - Tutorials
Visited: 3782 times
Networking, Programming and Graphics - Tutorials
Rating: Networking, Programming and Graphics - Tutorials
Networking, Programming and Graphics - Tutorials
Published: Tony Potter

This tutorial will explain how you can forward a web page to other URL using PHP forwarding.
It will be useful when you do not want to use other way of forwarding, like .htaccess permanent redirect, META redirect, Java redirect, etc.
This type of forwarding can be used only on a server with running PHP on it.
To do the forwarding create one 'index.php' file and paste the bellow listed code inside and do not forget to change 'http://www.domain.tld/folder/index.html' with the URL you want to forward to.
<?php
header
("Location: http://www.domain.tld/folder/index.html");
?>
Rate this tutorial:                    
Post Comment


    • posted on 2009-May-28 | 05:20:22 AM
      ok, but how I can do permanent redirect with php?

    • posted on 2009-May-28 | 05:23:37 AM
      This one should work:
      <?php
      header( "HTTP/1.1 301 Moved Permanently");
      header("Status: 301 Moved Permanently");
      header( "Location: http://www.domain.tld/");
      exit(0);
      ?>

      But better use .htaccess or any redirect on server level as it is better for the SE
Need a specific tutorial? Do not hesitate and submit a request!
Your e-mail: