問題描述
如何從php中製作的404自定義頁面獲取用戶嘗試訪問的鏈接 (How to get the link that the user tried to visit, from a 404 custom page made in php)
我有一個不同語言的網站,因此我想為每種語言顯示一個自定義的 404 頁面。
有沒有辦法找出用戶嘗試訪問的頁面(沒有存在)以便找出我應該顯示 404 頁面的語言?
Web 服務器是 Apache。非常感謝。
參考解法
方法 1:
if you use .htaccess
file for redirect then add
ErrorDocument 404 /yourdir/error/404page.php
then use request uri in session which stores the page user are visiting i.e.
$_SESSION['req_uri'] = $_SERVER['REQUEST_URI'];
then redirect user to $_SESSION['req_uri']
. where $_SESSION['req_uri']
is the page user trying to access.
(by dasen、Ajay Makwana)