![](/img/trans.png)
[英]Is it possibile/good idea to create Multiple PHP pages/urls from a single PHP file
[英]How to create multiple urls from single
我有以下鏈接: http : //server3.rciti.unsw.edu.au/stopandgo/index.php
現在,我的主管希望我向他認識的50個受訪者中的每個人分發自定義網址。 他創建了一個看起來像這樣的受訪者列表。
ID Person name 1 John 2 Ram 3 Charlie 4 Daniel ...and so on
他希望我提供以下自定義的網址: http : //server3.rciti.unsw.edu.au/stopandgo/index.php_1 ,依此類推(下划線后的數字是上面提到的個人ID)
這樣,他就可以在不透露受訪者身份的情況下識別受訪者。
我找不到解決此問題的方法。 我找到了許多網站,這些網站展示了如何將多個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 REWRITE
RewriteRule /index.php_(.*) /index.php?id=$1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.