Help! Need a bit of code.

SpaceshipSpaceship
SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Watch

Jeffler

Established Member
Impact
7
I need something that will redirect someone to a random page. So if they're at index.html/php/whatever, and the code has a list of a.com, b.com, or c.com, it picks a random one and redirects them to the site.
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Haven't tested, but should work:

PHP:
<?php
$domains = array('www.a.com', 'www.b.com', 'www.c.com');
$location = $domains[random(0, count($domains)-1)];
header('Location: http://' . $location);
?>
 
0
Close
Mikor said:
Haven't tested, but should work:

PHP:
<?php
$domains = array('www.a.com', 'www.b.com', 'www.c.com');
$location = $domains[random(0, count($domains)-1)];
header('Location: http://' . $location);
?>

Well how do you get it to redirect from there?
 
0
Close
0
Close
The only problem with that code is that the function is rand( and not random(.

:gl:
 
0
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Search: choose where to search from the All tab
Open the search at the top of any page. On the All tab, the list next to the search box lets you choose where to search: everything, all...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back