I have read through How to make a redirect in PHP, but everything there is based on having an HTML page for users to visit. In my case I am just sending users to an address ending in .php, whereupon they will be redirected to one of two places.
Here is the .php file in its entirety:
<?php
$num = Rand (1,2);
switch ($num) {
case 1: header('Location: http://blah.com/blah'); // "shortURL2"
break;
case 2: header('Location: http://yadda.com/yadda'); // "shortURL3"
break;
}
?>
It seems to work fine in all of my tests, but I want to make sure there isn't a fringe (or not-so-fringe) case user out there that would have an issue being redirected along this (admittedly convoluted) path:
shortURL1.com →1 longURL1.php →2 shortURL[2|3].com →3 longURL[2|3].com
- Link in email to subdomain 1, whereupon URL rewriting sends them to a .php file on subdomain 2
- Code above sends people to "case 1" or "case 2" URL back on subdomain 1
- Second round of URL rewriting on subdomain 1 lands user on one of two destination pages
I already know this is not the ideal way to do anything. This is what various limitations have brought me to, and if those could change I would share them. Suffice it to say that this is what I've got, and at this point I just need to make sure that everyone who clicks this link will end up on one of two sites and not floating in some kind of no-php-for-me-thanks limbo. . . or worse.