XAMPP使为windows配置本地LAMP堆栈变得轻而易举。因此,启用.htaccess
文件是一场噩梦,这让人非常失望。
我的问题:我有一个PHP应用程序,它需要apache.PHP来搜索应用程序中包含的/includes/
目录。要做到这一点,Apache中必须允许.htaccess
文件,并且.htaccess
文件必须指定includes目录的确切位置
问题是,我无法获得Apache配置来查看这些.htaccess
文件。我在大学安装这个应用程序时遇到了很大的麻烦,让那里的管理员帮忙安装。这应该不那么难,但出于某种原因,我无法让Apache发挥得很好。
这是我的设置:
c:'xampp
c:'xampp'htdocs
c:'xampp'apache'conf'httpd.conf
-我在其中进行了下面列出的更改c:'xampp'apache'bin'php.ini
-对该文件的更改影响PHP安装的位置值得注意的是,c:'xampp'php'php.ini
的更改毫无意义——这不是影响PHP安装的ini。
以下几行是我对httpd.conf
文件所做的添加
#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>
以下是包含在中的整个.htaccess
文件: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 "&"
php_value url_rewriter.tags "a=href,area=href,frame=src,input=src,fieldset="
includes目录存在于指定的位置。
当我尝试访问应用程序时,我收到以下错误:
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
致命错误:require(([function.request]:在第21行上打开C:'xampp'htdocs'application'menu'logon.php
中所需的include.general.inc
(include_path='.;C:''example''php''pear''random'(失败
包含路径c..'random'
是在上面列出的php.ini
文件中指定的。XAMPP安装无法允许htaccess.txt
文件中指定的另一个包含路径。
我猜httpd.conf
或htaccess.txt
文件可能有错误。。但它似乎没有读取CCD_ 21文件。我已经尽力做到彻底,所以请原谅这篇文章的冗长。
现在我知道了一个解决方法,可以简单地将include_path添加到PHP文件中,但我无法访问计划部署应用程序的位置上的php.ini
文件。然而,我将能够请求服务器管理员允许.htaccess
文件。
将htacces.txt
重命名为.htaccess
,并修改了httpd.conf
文件中的相应指令,一切似乎都正常。该应用程序建议在httpd中命名htaccess.txt
和ammend指令。这些显然是错误的(至少对于XAMPP堆栈而言(。
顺便说一句,如果应用程序需要部署到多个位置,使用ini_set((是一种更友好的方式,所以特别感谢这个指针。
- 为什么需要将.htaccess重命名为htaccess.txt
- 尝试使用set_include_path((设置include_path,看看这是否有帮助(作为中间修复(
- 通过phpinfo((验证要使用哪个php.ini
您可以使用ini_set((更改每个请求的include_path。这将完全避免使用htaccess。
My htaccess在XAMPP fine下工作-尽管某些模块在默认情况下是禁用的-您确定要启用的模块吗?
我认为您正在寻找的搜索引擎是:
AllowOverride All
我的猜测是,在examplep中,您需要在httpd.conf中启用AllowOverride(通过.htaccess(。这是一种简单的安全措施,可以防止新手安装可破解的平台:p
您需要在http.conf主文件中启用AllowOverride All。查看XAMPP_DIR/apache/conf/http.conf(内部
只需执行以下操作:
open file ...'xampp'apache'conf'httpd.conf
find line "LoadModule rewrite_module modules/mod_rewrite.so"
if here is a # before this line remove it.(remove comment)
其工作