Ip redirect script?

wealthy199

BANNED
Joined
Sep 24, 2007
Messages
543
Reaction score
1,254
Can someone make me a php script which allows me to list various ips to redirect to a certain page of my site rather then the default page?

For example if a user comes from 234.123.43.53 and goes to http://mysite.com/page1.php and they are listed in my script they should be redirected to a page such as http://mysite.com/page2.php.

Anyone want some quick money?
 
I don't have them yet, but I'll manually add them when I need to.
 
simpletds.com use it fo free

that didn't seem like english to me, nor did google translate could do a good job.

anyone here have any other suggestions?

a scrupt like that would be very nice :)
 
I havent tested this code for accuracy, but this should do the trick with very little modifications.
A much easier way is to use in_array(). No loops necessary. I prefer to use databases, but for simplicity I'll keep it with an array:

Code:
<?php
//add ips, to your list here, separating each with by a comma
$ip_array = array('255.255.255.255', '0.0.0.0');

//if they made it past the while loop, then the ip didnt match, send them to page1.php
if (in_array($_SERVER['REMOTE_ADDR'], $ip_array)) {
	header('Location: http://www.yoursite.com/page1.php');
}
?>

His actual request was for associating different pages with different IPs. This is a one to many relationship (page -> n..*). This would require a different array setup, or as I mentioned above a better way would be a database.

Wealthy, if you want something a bit more extensive let me know. I'm always looking to pickup side projects.
 
Last edited:
Could you do some thing like this in your htaccess


PHP:
RewriteEngine on
# If not googlebot IP address number 1
RewriteCond %{REMOTE_ADDR} !^66\.249\.65\.133$
# And if not googlebot IP address number 2
RewriteCond %{REMOTE_ADDR} !^66\.249\.67\.72$
# Then redirect all other requests to another page

RewriteRule !^page1/ http://www.mysite.com/page2/ [R=301,L]
 
Back
Top