bateman_ap
bateman_ap

Reputation: 1921

What value to use for include_path in .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?

Upvotes: 1

Views: 1094

Answers (3)

nalply
nalply

Reputation: 28717

You can use relative paths, i.e.

php_value include_path ../../includes:/usr/share/pear

is okay. Note, relative to the directory the .htaccess file is in.

Upvotes: 1

Shiki
Shiki

Reputation: 16808

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:

$root = dirname(__FILE__);
set_include_path(get_include_path() . PATH_SEPARATOR . '/includes/');
set_include_path(get_include_path() . PATH_SEPARATOR . '/externallib/');

Upvotes: 0

Your Common Sense
Your Common Sense

Reputation: 157839

I never use include_path but always provide an absolute path based on the DOCUMENT_ROOT

Upvotes: 0

Related Questions