我正在尝试在找不到用户时创建一个未找到的页面。当您在地址栏中输入错误的用户名时,它将转到未找到的页面。我得到的代码不起作用,但输入正确的用户名时它可以工作。
<? session_start();
include "includes/dbconfig.php";
// CHANGE USERNAME TO LOWERCASE
$username = strtolower($_GET[user]);
// CHECK IF THE USER EXISTS
$check_user = mysql_query("SELECT * FROM users WHERE username='$username'");
// WHILE LOOP THRU DATABASE
while ($display = mysql_fetch_array($check_user)) {
// GET FIELD HIDDENAUTH
$thepowers = $display['hiddenauth'];
// GET THE POWERS TO SEE IF DJ OR NOT
if ($thepowers == "no") {
include "profile_members.php";
} else {
// IF NO HIDDENAUTH FOUND REDIRECT TO ERROR PAGE
header("Location: notfound.php");
exit();
}}
?>
..htaccess有这个...
RewriteEngine On
Options +Followsymlinks All
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.* - [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*/images/(.*)$ /images/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*/uploads_user/(.*)$ profiles/1/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ profile.php?user=$1 [L]
有人可以帮忙吗?