我有以下链接:http://server3.rciti.unsw.edu.au/stopandgo/index.php
现在我的主管想让我把一个定制的url分发给他认识的50个应答者。他创建了一个应答者列表,看起来像这样。
<>之前个人姓名约翰一书2公3查理4丹尼尔…等等......之前他想让我想出以下自定义的url:http://server3.rciti.unsw.edu.au/stopandgo/index.php_1等(下划线后面的数字是上面提到的人id)
这样,他就可以在不暴露被调查者身份的情况下识别他们。
我找不到解决这个问题的方法。我发现许多网站展示了如何将多个url合并为一个,但我想要相反的。
我也试过小url,但是当我点击小url时,它会引导我到相同的原始链接。
给他们每个人一个链接,看起来像这样:
http://server3.rciti.unsw.edu.au/stopandgo/index.php/?id=1
然后,使用php获取访问过该站点的用户:
if (isset($_GET['id']) && is_numeric($_GET['id'])) //if a specific and valid user has visited the site
$user = $_GET['id']; //will return 1, whom you know to be John
//log John as having visited the site
$file = 'visited.txt'; //open the file and get existing content
$current = file_get_contents($file); //append a new person to the end of the file
$current .= $user."'n"; // Write the contents back to the file
file_put_contents($file, $current); //write to the file
}
然后,给Ram链接http://server3.rciti.unsw.edu.au/stopandgo/index.php/?id=2
-
使用$_GET[]变量:
$id = $_GET["id"];
if(isset($id) && is_numeric($id)){
//do something
}
-
使用HTACCESS重写
RewriteRule /index.php_(.*) /index.php?id=$1