php mysql htaccess首次使用

php mysql htaccess首次使用,php,mysql,.htaccess,Php,Mysql,.htaccess,我正在使用php和mysql创建一个配置文件页面,使用get方法从url获取用户名,如下所示(http://localhost/Unnamed%20Site%202/resources/username)所以我使用了.htaccess,但问题是我放置.htaccess的根文件夹消失了,我从浏览器中得到一条错误消息: 内部服务器错误 服务器遇到内部错误或配置错误,无法完成您的请求。 请与服务器管理员联系,admin@localhost并告知他们错误发生的时间,以及您可能采取的任何可能导致错误的措施

我正在使用php和mysql创建一个配置文件页面,使用get方法从url获取用户名,如下所示
(http://localhost/Unnamed%20Site%202/resources/username)
所以我使用了.htaccess,但问题是我放置.htaccess的根文件夹消失了,我从浏览器中得到一条错误消息: 内部服务器错误 服务器遇到内部错误或配置错误,无法完成您的请求。 请与服务器管理员联系,admin@localhost并告知他们错误发生的时间,以及您可能采取的任何可能导致错误的措施。 有关此错误的更多信息,请参阅服务器错误日志。 有人能帮我吗

这是appache_error.log 这是profile.php 此错误消息

[Mon Mar 18 19:13:52 2013][alert][client 127.0.0.1]C:/wamp/www/Unnamed Site 2/resources/.htaccess:无效命令“RewriteEngine”,可能拼写错误或由服务器配置中未包含的模块定义,请参考:
http://localhost/Unnamed%20Site%202/resources/account-setting.php


提示缺少
mod_rewrite
模块。您必须首先安装和/或配置它,然后才能使用它。

确保在Apache配置文件中启用了重写扩展。在httpd.confCorrect中取消注释:
LoadModule rewrite\u module modules/mod\u rewrite.s
。如果不启用“重写引擎”,则无法使用它!谢谢你tomhallam这是隐藏的钥匙我该怎么感谢你
 [Mon Mar 18 19:13:05 2013] [error] [client 127.0.0.1] PHP   1. {main}() C:\\wamp\\www\\Unnamed Site 2\\resources\\profile.php:0, referer: http://localhost/Unnamed%20Site%202/resources/
    [Mon Mar 18 19:13:16 2013] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
    [Mon Mar 18 19:13:21 2013] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
    [Mon Mar 18 19:13:52 2013] [alert] [client 127.0.0.1] C:/wamp/www/Unnamed Site 2/resources/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration, referer: http://localhost/Unnamed%20Site%202/resources/account-setting.php
    [Mon Mar 18 19:13:52 2013] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
    [Mon Mar 18 19:23:09 2013] [alert] [client 127.0.0.1] C:/wamp/www/Unnamed Site 2/resources/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration, referer: http://localhost/Unnamed%20Site%202/resources/profile.php
    [Mon Mar 18 19:23:09 2013] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
    [Mon Mar 18 19:23:09 2013] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
    [Mon Mar 18 19:23:11 2013] [alert] [client 127.0.0.1] C:/wamp/www/Unnamed Site 2/resources/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration, referer: http://localhost/Unnamed%20Site%202/
    [Mon Mar 18 19:23:11 2013] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
    [Mon Mar 18 19:23:12 2013] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
    [Mon Mar 18 19:23:13 2013] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
    [Mon Mar 18 19:23:14 2013] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
    [Mon Mar 18 19:23:16 2013] [alert] [client 127.0.0.1] C:/wamp/www/Unnamed Site 2/resources/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration, referer: http://localhost/
    [Mon Mar 18 19:23:16 2013] [error] [client 127.0.0.1] client denied by server configuration: C:/Apache2, referer: http://localhost/Unnamed%20Site%202/
    [Mon Mar 18 19:23:16 2013] [error] [client 127.0.0.1] client denied by server configuration: C:/Apache2, referer: http://localhost/Unnamed%20Site%202/
    [Mon Mar 18 19:23:16 2013] [error] [client 127.0.0.1] client denied by server configuration: C:/Apache2, referer: http://localhost/Unnamed%20Site%202/
    [Mon Mar 18 19:23:16 2013] [error] [client 127.0.0.1] client denied by server configuration: C:/Apache2, referer: http://localhost/Unnamed%20Site%202/
    [Mon Mar 18 19:23:16 2013] [error] [client 127.0.0.1] client denied by server configuration: C:/Apache2, referer: http://localhost/Unnamed%20Site%202/
    [Mon Mar 18 19:23:16 2013] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
// 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
         {
             // this line is to redirect the unexist users to the index.php
            echo "<meta http-equiv=\"refresh\" content=\"0; url=http://localhost/Unnamed Site 2/resources/index.php\">";
            exit();  
         }
      }
   }
?>
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?u=$1 [L]