使用首次PHP的MySQL的htaccess [英] php mysql htaccess used for the first time

查看:136
本文介绍了使用首次PHP的MySQL的htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了PHP和MySQL使用get梅索德从URL像这样(HTTP GET的用户名来创建一个配置文件页面://本地主机/无名%20Site%202 /资源/用户名)所以我用了htaccess的,但问题是,在这里我把.htaccess中的根文件夹是消失了,我从浏览器的错误信息: 内部服务器错误 服务器遇到一个内部错误或配置错误,无法完成您的请求。 请与服务器管理员联系,管理员@本地和告知发生错误​​的时候他们,任何你可能会做,可能造成的错误。 这个错误的详细信息,可在服务器错误日志。 任何人都可以帮我吗?

这是appache_error.log

  [周一3月18日十九时13分05秒2013] [错误] [客户127.0.0.1] PHP 1. {主}()C:\\ \\瓦帕WWW \\未命名的网站2 \\ \\资源profile.php:0,引用者:HTTP://本地主机/无名%20Site%202 /资源/
    [周一03月18日19点13分16秒2013] [错误] [客户127.0.0.1]文件不存在:C:/wamp/www/favicon.ico
    [周一03月18日19点13分21秒2013] [错误] [客户127.0.0.1]文件不存在:C:/wamp/www/favicon.ico
    [周一3月18日19点13分52秒2013] [警惕] [客户127.0.0.1] C:/ WAMP / WWW /未命名的网站2 /资源/的.htaccess:无效的命令RewriteEngine叙述',也许拼错或模块中定义不包括在服务器结构中,引用者:HTTP://localhost/Unnamed%20Site%202/resources/account-setting.php
    [周一03月18日19点13分52秒2013] [错误] [客户127.0.0.1]文件不存在:C:/wamp/www/favicon.ico
    [周一3月18日十九时23分09秒2013] [警惕] [客户127.0.0.1] C:/ WAMP / WWW /未命名的网站2 /资源/的.htaccess:无效的命令RewriteEngine叙述',也许拼错或模块中定义不包括在服务器结构中,引用者:HTTP://localhost/Unnamed%20Site%202/resources/profile.php
    [周一03月18日十九时23分09秒2013] [错误] [客户127.0.0.1]文件不存在:C:/wamp/www/favicon.ico
    [周一03月18日十九时23分09秒2013] [错误] [客户127.0.0.1]文件不存在:C:/wamp/www/favicon.ico
    [周一03月18日19点23分十一秒2013] [警惕] [客户127.0.0.1] C:/ WAMP / WWW /未命名的网站2 /资源/的.htaccess:无效的命令RewriteEngine叙述',也许拼错或模块中定义不包括在服务器结构中,引用者:HTTP://本地主机/未命名%20Site%202 /
    [周一03月18日19点23分十一秒2013] [错误] [客户127.0.0.1]文件不存在:C:/wamp/www/favicon.ico
    [周一3月18日19点23分12秒2013] [错误] [客户127.0.0.1]文件不存在:C:/wamp/www/favicon.ico
    [周一03月18日19时23分13秒2013] [错误] [客户127.0.0.1]文件不存在:C:/wamp/www/favicon.ico
    [周一03月18日19时23分十四秒2013] [错误] [客户127.0.0.1]文件不存在:C:/wamp/www/favicon.ico
    [周一3月18日19时23分16秒2013] [警惕] [客户127.0.0.1] C:/ WAMP / WWW /未命名的网站2 /资源/的.htaccess:无效的命令RewriteEngine叙述',也许拼错或模块中定义不包括在服务器结构中,引用者:HTTP://本地主机/
    [周一03月18日19时23分16秒2013] [错误] [客户127.0.0.1]客户拒绝的服务器配置:C:/ Apache2的,引用者:HTTP://本地主机/无名%20Site%202 /
    [周一03月18日19时23分16秒2013] [错误] [客户127.0.0.1]客户拒绝的服务器配置:C:/ Apache2的,引用者:HTTP://本地主机/无名%20Site%202 /
    [周一3月18日19时23分16秒2013] [错误] [客户127.0.0.1]客户拒绝的服务器配置:C:/ Apache2的,引用者:HTTP://本地主机/无名%20Site%202 /
    [周一3月18日19时23分16秒2013] [错误] [客户127.0.0.1]客户拒绝的服务器配置:C:/ Apache2的,引用者:HTTP://本地主机/无名%20Site%202 /
    [周一3月18日19时23分16秒2013] [错误] [客户127.0.0.1]客户拒绝的服务器配置:C:/ Apache2的,引用者:HTTP://本地主机/无名%20Site%202 /
    [周一03月18日19时23分16秒2013] [错误] [客户127.0.0.1]文件不存在:C:/wamp/www/favicon.ico
 

,这是profile.php

  // updatede为使用GET梅索德为GE从URL nedded数据
如果(使用isset($ _ GET ['U']))
{
      $用户名= mysql_real_escape_string($ _ GET ['U']);
      如果(ctype_alnum($用户名))
     {


      //检查用户存在
         $检查=请求mysql_query(选择用户名,FIRST_NAME从用户其中用户名='$用户名)或死亡(mysql_error());
         如果(mysql_num_rows($检查)== 1)
         {
           $ GET = mysql_fetch_assoc($检查);
           $ USERNAME = $ GET ['用户名'];
           $ FNAME = $ GET ['如first_name'];
         }
         其他
         {
             //此行是对unexist用户重定向到的index.php
            回声< META HTTP-当量= \刷新\内容= \0; URL = HTTP://本地主机/未命名的网站2 /资源/ index.php文件\>中;
            出口();
         }
      }
   }
?>
 

的.htaccess

  RewriteEngine叙述上
重写规则^([A-ZA-Z0-9 _-] +)$ profile.php?U = $ 1 [L]
 

解决方案

此错误信息

  

[周一3月18日19点13分52秒2013] [警惕] [客户127.0.0.1] C:/ WAMP / WWW /未命名的网站2 /资源/的.htaccess:无效的命令RewriteEngine叙述,也许是拼写错误或定义的模块的不包括在服务器配置,引用者: HTTP://localhost/Unnamed%20Site%202/resources/account-setting.php

暗示漏了的mod_rewrite 模块。您必须先安装和/或配置,然后才能使用它。

i am using the php and mysql to create a profile page using the get methode to get the username from the url like this (http://localhost/Unnamed%20Site%202/resources/username) so i used the .htaccess but the problem was that the root folder where i put the .htaccess was disappear and i get an error msg from the browser : Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. anyone can help me??

this is the appache_error.log

 [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

and this is the profile.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
         {
             // 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();  
         }
      }
   }
?>

.htaccess

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?u=$1 [L]

解决方案

This error message

[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

hints at a missing mod_rewrite module. You must first install and/or configure it, before you can use it.

这篇关于使用首次PHP的MySQL的htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆