試圖國防部重寫(的.htaccess):htaccess的空行中MySQL數據庫
http://domain.com/show.php?id=2 到 http://domain.com/show/id/2 使用: 重寫規則顯示/ ID /(.*)$ show.php ID = $ 1
並且將用戶重定向到錯誤頁面if(row [id])不存在於db中,現在他們看到沒有Value的空頁面。
謝謝
試圖國防部重寫(的.htaccess):htaccess的空行中MySQL數據庫
http://domain.com/show.php?id=2 到 http://domain.com/show/id/2 使用: 重寫規則顯示/ ID /(.*)$ show.php ID = $ 1
並且將用戶重定向到錯誤頁面if(row [id])不存在於db中,現在他們看到沒有Value的空頁面。
謝謝
你可以使用例如這樣的事情:
RewriteRule ^(.*)/ show.php?id=$1
和:
$id = $_GET["id"];
..... MySQL的..
if (!$page_not_found) {
header('This is not the page you are looking for', true, 404);
include('your_404_page.php');
exit();
}
mod_rewrite無法檢查您的數據庫。你應該檢查一個現有的條目,並從那裏重定向(或直接顯示錯誤消息)。
的這一點,只有一部分。正如你所做的那樣,htaccess可以處理的是將你的靜態/ SEO URI重定向到動態格式。它不知道id = 2是否合法。你必須在你的PHP代碼中處理它,然後做一個'header(「location:xxxxxx」);'調用跳轉到一個錯誤頁面。 –