PX : code

Redirection Script by Arnold Gamboa
Download this code


Hi all. I'd like to share this simple php script of mine. I hope this helps.

<b>file name - redirect.php</b>

<?
$remote = getenv("HTTP_HOST");
$fp = fopen("redirect.txt", "r"); 

while (!feof($fp)):
$line = fgets($fp,1800); 
$line_list = explode("|",$line); 

$url1 = $line_list[0];
$url2 = $line_list[1];
$redirect = $line_list[2];

if ($url1 == $remote or $url2 == $remote):
Header ("Location:$redirect");
$closefp = fclose($fp); 
endif;
endwhile;
$closefp = fclose($fp); 
?>

<b>file name - redirect.txt </b>(here is where you will put your domain names and directory)

domain1.com|www.domain1.com|subdirectory/index.php
domain2.com|www.domain2.com|subdirectory/index.php

at the very top of your main accounts index file, put:

<? require("redirect.php");?>

don't forget to rename it to index.php or index.php3

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.