我正在尝试在我的本地计算机上运行我的在线网站。我偶然发现了一个问题。
这是我的htaccess
AddDefaultCharset UTF-8
Options -Indexes
#php_value include_path .:/home/sites/www.example.it/example.it/htdocs/conf/
php_value include_path .:/XAMPP/htdocs/conf/
php_value display_errors on
php_value upload_max_filesize 20M
php_value post_max_size 50M
php_flag magic_quotes_gpc Off
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
#RewriteBase /
#RewriteCond %{HTTP_HOST} ^example.it [NC]
#RewriteRule ^(.*)$ http://www.example.it/ [L,R=301]
</IfModule>
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} /common.*
RewriteRule ^common/(.*) resources/media/common/$1
RewriteCond %{REQUEST_URI} /upload/img.*
RewriteRule ^upload/img/(.*)$ wapp/ir.php?path=$1&%{QUERY_STRING}
RewriteCond %{REQUEST_URI} /upload.*
RewriteRule ^upload/(.*) resources/upload/$1
RewriteCond %{REQUEST_URI} !/google.*
RewriteCond %{REQUEST_URI} !/common.*
RewriteCond %{REQUEST_URI} !/upload.*
RewriteCond %{REQUEST_URI} !/upload/img/.*
RewriteCond %{REQUEST_URI} !/wapp/ir.php
RewriteRule ^(.*)$ wapp/index.php?url=$1
</IfModule>
我收到的错误:
警告: require_once(conf.inc.php): failed to open stream: No such file or directory in C:\XAMPP\htdocs\wapp\index.php on line 2
致命错误: require_once(): Failed opening required 'conf.inc.php' (include_path='.:/XAMPP/htdocs/conf/') in C:\XAMPP\htdocs\wapp\index.php on line 2
我该如何解决?也许它处理xampp用户的特权......
修改
getcwd()给了我 C:\ XAMPP \ htdocs \ wapp
conf.inc.php位于: C:\ XAMPP \ htdocs \ conf \
index.php中的require: require_once(“conf.inc.php”);
答案 0 :(得分:9)
尝试chdir(dirname(__FILE__))
这会设置文件路径的相对路径。
因此C:\XAMPP\htdocs\wapp\
成为您的“根目录”,因此config.inc.php
与C:\XAMPP\htdocs\wapp\config.inc.php
相同。如果仍然没有检查你的文件路径
编辑:
你必须在那里穿越。检查项目的相对根(getcwd()
)。我认为你必须将C:\XAMPP\htdocs\wapp\
改为你的要求:
require_once ('../conf/conf.inc.php')
..
让你上一个目录
好的就是这样做:
require_once("../conf/conf.inc.php");