我不是100%肯定我在哪裏搞亂這件事,但我試圖做的是(最有可能的,如果文件存在位檢查):獲取URL查詢字符串和PHP
- 獲取頁面的查詢,例如
example.com?example
- 然後使用字符串的文件路徑(
in this case news/example.php
) - 然後看該文件是否存在
- 然後,如果確實如此,包括文件的工作,如果沒有迴應一個錯誤信息。
這是我的代碼有:
$getPage = $_SERVER['QUERY_STRING'];
$page = "news/"+$getPage+".php";
if (file_exists($page)) {
include $page;
} else {
echo "The page you are looking for cannot be found. To return back to the main page click <a href='example.com'>here</a>";
}
如果查詢有可能成爲example.com?news/example.php
它不會是世界末日,但是越短越好;把它作爲文件名,沒有擴展名會更好。
聽起來好像你想要url重寫 –
你想讓人們能夠例如'http://example.com/index.php ?p = conctact',還是那不是你的問題? – Tom
當心[RFI](https://en.wikipedia.org/wiki/File_inclusion_vulnerability) – Bigood