A link redirected 10 %

Something like this will get you started on writing your own. Hope it's useful...

PHP:
<?php 

$redirectRatio = 10 ; // as a percent
$redirectURL = "http://www.bing.com" ;
$normalURL = "http://www.google.com" ;

echo (rand(1, 100) > $redirectRatio) ? ($normalURL) : ($redirectURL)

?>
 
Not *exactly* what u're asking but good enough as a starting point... ;)
Code:
if (Math.floor((Math.random()*10)+1) == 5) window.location = 'http://www.google.com';
Haven't tested it, just going by heart but should work. Put it in the onclick section and change google to whatever your redirection URL is:
a href=# onclick=
if you need EXACTLY 10% you need to keep track of your visitors and make a serverside script: this is a quick hack, but has the advantage of working with minimal hassle. HTH!
 
Last edited:
Hi, and thanks for the speed answers. If i understand it right ?

When a user click the link, and he is in the 10 % ratio, then the script is redirected to bing.com
Is the ratio over 10 % he is redirected to google.com ?

I made a site, and there 100 user click a link. And the script redirected 10 user to bing.com
and 90 user to google.com ?
 
A serverside script is a script that executes on the server : for example PHP > means that the user connecting to your website won't view the script but only it results once the server has executed it.

Javascript isn't a server side script as the user's browser 'downloads' the script, then executes it on his own computer. This is why you msut have java installed on your computer to view some sites.
 
what is a serverside script. Can you help me ? please :confused:
It means -in layman's terms- you can create a simple html page even on your computer and it'll work just fine from there without the need of anything else. And of course it'll work if uploaded onto your host too. The php solution that fellow @rendesr offered is equally effective and even better if you need to cloak the redirection URL (not possible in a safe way with simple js) but will require you to edit a php file on the server. In any case no big deal.
 
Back
Top