![]() |
anyone with a simple php script?
I need a php script that will split my hits between 2 urls. for example.
1 hit in = redirects to url 1 another hit in = redirects to url 2 another hit in = redirects to url 1 so on and so forth...... |
PHP Code:
I do not claim that this is the best solution :) |
thank you:)
|
PHP Code:
Here's a quick and dirty UNTESTED! way to do it... If you only want to redirect between 2 URLs and you want to keep them pretty even but not necessarily EXACTLY even, I would do something like that that didn't involve file I/O... any time you touch the disk it's going to get slow especially if you're going to throw a lot of traffic at it. This just checks to see if the current second is even or odd and then forwards to either url1 or url2... If you're only talking about 2 URLs and not needing to track any stats, I'd say something like this would work pretty damn well. :)\ So just copy that code into a php file, update the 2 urls and send traffic directly to the php page you create. Good Luck! -KC |
thx fellas, i went with KC's seems to be working great sofar:)
i appreciate the input |
What's wrong with how i am doing it
<? $urls = array( 1 => "http://www.url1.com", 2 => "http://www.url2.com", 3 => "http://www.url3.com", 4 => "http://www.url4.com", ); srand ((double) microtime() * 1000000); $randnum = rand(1,4); $goto = $urls[$randnum]; header("Location: $goto"); ?> |
4Pics,
Your's will work well also... :) For something simple like this, as long as it isn't hitting a database or reading & writing to a text file, just about ANYTHING will work... -KC |
I dunno what you're using this for, but you might consider stashing a cookie so that if/when the user/visitor ever comes back, he gets the alternate URL on the second visit.
Then you can do a "porn site" Survivor test where you can run 3-4-5 front ends, all receiving equal amounts of traffic and figure out which one is doing worst - pull it out, redesign it and put it back in the rotation and repeat. |
Do it with java script - no server load + it will work for 99% of browsers.... if a simple java script wont work on the user, how can you expect a sponsor to track the signup?? :)
|
Quote:
I think relying on a browser to do a rotation job is unreliable. Especially when you have a fast server side technology like PHP available to you. (as this guy did) PHP doing something like this could easily hanle millions of hits per day, depending on the hardware. Speed and server load won't be a problem with something like this. -KC |
Yeah, i thought about javascript, but like you say most asswipes have it off or its not supported in some way, so php seemed like the only way togo, as far as cookies go, these visitors will only hit the site once (98% sure of that) so no need to stick a big fat nasty cookie in thier pc:)
|
Quote:
|
All times are GMT -7. The time now is 12:48 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123