我正在创建一个处理个人资料页面的网站,我需要从 URL 获取用户名,直到此时一切正常,但我在使用.htaccess时遇到问题,我不知道如何解决此错误这是我的第一次使用 .htaccess 我使用的是 WAMP 包,在我添加 .htaccess 文件并隐藏包含它的文件夹后,浏览器给了我这个错误。
内部服务器错误 服务器遇到内部错误或配置错误,无法完成您的请求。请通过 admin@localhost 联系服务器管理员,告知他们此错误发生的时间,以及您在此错误之前执行的操作。服务器错误日志中可能提供有关此错误的更多信息。 这是 profile.php 的一部分
配置文件.php
// updatede for using the GET methode for ge the data nedded from the url
if(isset($_GET['u']))
{
$username = mysql_real_escape_string($_GET['u']);
if(ctype_alnum($username))
{
//check user exist
$check = mysql_query("SELECT user_name, first_name FROM user WHERE user_name = '$username' ")or die(mysql_error());
if (mysql_num_rows($check)==1)
{
$get = mysql_fetch_assoc($check);
$username = $get['user_name'];
$fname = $get['first_name'];
}
else
{
echo "<h2>User does not Exist!!</h2>";
exit();
}
}
}
echo "$username";
?>
.htaccess
RewriteEngine On
RewriteRule^([a-zA-Z0-9_-]+)$ profile.php?u=$1
RewriteRule^([a-zA-Z0-9_-]+)/$ profile.php?u=$1