htaccess的文件,PHP,包括目录和窗口XAMPP配置恶梦 [英] htaccess files, php, includes directories, and windows XAMPP configuration nightmare

查看:579
本文介绍了htaccess的文件,PHP,包括目录和窗口XAMPP配置恶梦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

XAMPP使配置本地LAMP堆栈窗口变得轻而易举。所以,这是相当令人失望的是使htaccess的文件是这样的噩梦。

我的问题:
我有一个需要阿帕奇/ PHP来搜索包含在应用程序内的/包括/目录下的PHP应用程序。要做到这一点,htaccess的文件必须被允许在Apache和htaccess的文件必须明确指定,其中包括目录。

但问题是,我不能让我的Apache的配置,查看这些htaccess的文件。我曾在大学安装这个程序,并获得管理员有帮助的设置主要麻烦。这不应该是这么辛苦,但出于某种原因,我不能获得Apache发挥好。

这是我的设置:

C:\ XAMPP
C:\ XAMPP \ htdocs中
C:\ XAMPP的\ apache的\的conf \ httpd.conf文件 - 在那里我做了下面 C:\ XAMPP的\ apache的\斌\ php.ini中 - 在更改此文件影响PHP安装
有趣的是,要注意的是C:\ XAMPP \ PHP \ php.ini中的变化意味着什么 - 这不是影响PHP安装的INI。

以下行是增加我向httpd.conf文件

  #AccessFileName的.htaccess
AccessFileName htaccess.txt
#
#以下行prevent的.htaccess和htpasswd的
从#文件,Web客户端被查看。
#
#<文件〜^ \ HT。>
<文件〜^ htaccess的\>
    订购允许,拒绝
    所有拒绝
< /文件>

<目录C:/ XAMPP的/ htdocs中>
#
#的AllowOverride控制什么指令可以被放置在
#.htaccess文件。
#它可以是全部,无,或关键字的任意组合:
#选项FileInfo的项AuthConfig极限
#
    设置AllowOverride所有
#
#控制谁可以从服务器获得资料。
#
    订购允许,拒绝
    所有允许
< /目录>
 

以下是包含在整个htaccess文件: C:\ XAMPP \ htdocs中\程序\ htaccess.txt

 <文件〜\。公司$>
  订单拒绝,允许
  所有拒绝
< /文件>

php_value DEFAULT_CHARSETUTF-8
php_value include_path中; C:\ XAMPP \ htdocs中\程序\包含
php_value了register_globals 0
php_value magic_quotes_gpc的0
php_value magic_quotes_runtime的0
php_value magic_quotes_sybase 0
php_value session.use_cookies 1
php_value session.use_only_cookies 0
php_value session.use_trans_sid指定1
php_value的session.gc_maxlifetime 360​​0
php_value arg_separator.output&放大器;放大器;
php_value url_rewriter.tagsA = HREF,面积= HREF,帧= SRC,输入= SRC,字段集=
 

该目录包括存在于指定的位置。

当我尝试访问我收到以下错误的应用程序:

 警告:要求(include.general.inc)[function.require]:未能打开流:在C中没有这样的文件或目录:\ XAMPP \ htdocs中\程序\菜单\ logon.php第21行
 

致命错误:要求()[function.require]:无法开口要求include.general.inc(include_path中=; C:\ XAMPP \ PHP \梨\随机')在C:\ XAMPP \ htdocs中\程序\在线21菜单\ logon.php

在包括路径为c .. \随机\在上面列出的php.ini文件中指定。 XAMPP的安装失败让其他包括如htaccess.txt文件中指定的路径。

请帮忙!我猜有可能是与httpd.conf文件或将htaccess.txt文件中的错误..但它似乎并没有被读htaccess文件。我试着要尽可能详细所以请原谅职位的详细程度。

现在我知道一种解决方法可以是简单地添加和include_path到PHP文件,但我不会有机会获得在我计划部署我的应用程序的位置php.ini文件。我会,不过,可以要求服务器管理员允许htaccess的文件。

更新:更名htacces.txt为.htaccess,并修改了相应的指令在httpd.conf文件和所有似乎工作。该应用程序建议htaccess.txt的命名和httpd的的ammended指令。这些显然是错误的(至少在XAMPP栈)。谢谢您的帮助。

顺便说一句,使用ini_set()是一个更友好的方式,如果应用程序需要部署到多个位置,以便特别是对指针的感谢。

解决方案
  1. 为什么你需要重新命名的.htaccess htaccess.txt
  2. 尝试使用 set_include_path(),看看有没有什么帮助(作为中间固定)设置的include_path
  3. 验证其php.ini中通过的phpinfo使用()

XAMPP makes configuring a local LAMP stack for windows a breeze. So it's quite disappointing that enabling htaccess files is such a nightmare.

My problem:
I've got a PHP application that requires apache/php to search for an /includes/ directory contained within the application. To do this, htaccess files must be allowed in apache and the htaccess file must specify exactly where the includes directory is.

Problem is, I can't get my apache config to view these htaccess files. I had major hassles installing this app at uni and getting the admins there to help with the setup. This shouldn't be so hard but for some reason I just can't get apache to play nice.

This is my setup:

c:\xampp
c:\xampp\htdocs
c:\xampp\apache\conf\httpd.conf - where I've made the changes listed below
c:\xampp\apache\bin\php.ini - where changes to this file affect the php installation
It is interesting to note that c:\xampp\php\php.ini changes mean nothing - this is NOT the ini that affects the php installation.

The following lines are additions I've made to the httpd.conf file

#AccessFileName .htaccess
AccessFileName htaccess.txt
#
# The following lines prevent .htaccess and .htpasswd 
# files from being viewed by Web clients. 
#
#<Files ~ "^\.ht">
<Files ~ "^htaccess\.">
    Order allow,deny
    Deny from all
</Files>

<Directory "c:/xampp/htdocs">
#
# AllowOverride controls what directives may be placed in 
# .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride All
#
# Controls who can get stuff from this server.
#
    Order allow,deny
    Allow from all
</Directory>

The following is the entire htaccess file contained in: c:\xampp\htdocs\application\htaccess.txt

<Files ~ "\.inc$">
  Order deny,allow
  Deny from all
</Files>

php_value default_charset "UTF-8"
php_value include_path ".;c:\xampp\htdocs\application\includes"
php_value register_globals 0
php_value magic_quotes_gpc 0
php_value magic_quotes_runtime 0
php_value magic_quotes_sybase 0
php_value session.use_cookies 1
php_value session.use_only_cookies 0
php_value session.use_trans_sid 1
php_value session.gc_maxlifetime 3600
php_value arg_separator.output "&amp;"
php_value url_rewriter.tags "a=href,area=href,frame=src,input=src,fieldset="

The includes directory exists at the location specified.

When I try to access the application I receive the following error:

Warning: require(include.general.inc) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\application\menu\logon.php on line 21

Fatal error: require() [function.require]: Failed opening required 'include.general.inc' (include_path='.;C:\xampp\php\pear\random') in C:\xampp\htdocs\application\menu\logon.php on line 21

The include path c..\random\ is specified in the php.ini file listed above. The xampp install fails to allow another include path as specified in the htaccess.txt file.

Please help! I'm guessing there's probably an error with the httpd.conf OR the htaccess.txt file.. but it doesn't seem to be reading the htaccess file. I've tried to be as thorough as possible so forgive the verbosity of the post.

Now I know a workaround could be to simply add the include_path to the php file, but I'm not going to have access to the php.ini file on the location I plan to deploy my app. I will, however, be able to request the server admin allows htaccess files.

Update: renamed htacces.txt to .htaccess and ammended the appropriate directives in the httpd.conf file and all seems to work. The application suggested the naming of htaccess.txt and the ammended directives in the httpd. These are obviously wrong (at least for a xampp stack). Thanks for the help.

By the way, using ini_set() is a much friendlier way if the app needs to be deployed to multiple locations so thanks especially for that pointer.

解决方案

  1. Why do you need to rename .htaccess to htaccess.txt
  2. Try setting the include_path using set_include_path() and see if that helps (as an intermediate fix)
  3. Verify which php.ini to use through a phpinfo()

这篇关于htaccess的文件,PHP,包括目录和窗口XAMPP配置恶梦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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