.htaccess 中的 include_path 使用什么值
目前,在我的 .htaccess 文件中,我正在设置 include_path
,如下所示:
php_value include_path /mnt/webs/mysite/includes:/usr/share/pear
但是,如果我需要将我的网站放在新服务器上,那么这并不是很好,因为我需要经历大量的网站更新每个.htaccess。 文件夹(我在一台服务器上运行各种不同的站点,因此每个 .htaccess 文件和包含路径都会不同)。
基本上想要一种方法来基本上说“使用站点根目录中名为 includes
的 这里有一个相关的问题,我有人使用:
inclue(dirname(__FILE__)."/inc2.php");
但是这是在代码中,每次都可能有点烦人,但是我应该使用这个方法并放弃使用 .htaccess 的想法吗?
Currently in my .htaccess file I am setting include_path
such as this:
php_value include_path /mnt/webs/mysite/includes:/usr/share/pear
However this isn't great if I need to put my sites on a new server as I need to go through a whole load of sites updating each .htaccess. Basically would like a way to basically say "use the folder called includes
in the site root (I run a variety of different sites off one server so each .htaccess file and include path will be different).
In a related question on here I had someone use:
inclue(dirname(__FILE__)."/inc2.php");
But this is in code and might be a bit annoying to do everytime, however should I just use this method and scrap the idea of using .htaccess?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可以使用相对路径,ie
就可以了。请注意,相对于
.htaccess
文件所在的目录。You can use relative paths, i.e.
is okay. Note, relative to the directory the
.htaccess
file is in.我从不使用 include_path 但总是提供基于 DOCUMENT_ROOT 的绝对路径
I never use include_path but always provide an absolute path based on the DOCUMENT_ROOT
我通常的做法是使用根文件夹(可能是 public_html)作为基础在 PHP 中设置相对包含路径。
例如,您的根文件夹中可以有一个名为 common.php 的核心文件 - 您可以将所有包含路径放在这里:
The way I usually do it is set relative include paths in PHP using the root folder (maybe public_html) as base.
For example, you can have a core file named common.php in your root folder -- you can put all your include paths here: