PHP

Set PHP Include path via .htaccess file

TAGs: 2 Comment

Posted By: eligeske on in PHP

When working with many websites on one development environment using Apache you may run into the issue where one website references a different websites files.  This usually happens if you have a php include path set in your ini file for one site and not the other.  A quick way to keep this from happening is using an htaccess file to set your php include path for each site. (Personally I think this is just an easier way to maintain them)

Either create an .htaccess file or edit an existing one in the website root.  Please note that for my development environment I use vhosts in my apaches config settings so I can call my sites directly by a URL and NOT using localhost.  Therefore I can set an individual include path in each site’s directory.

Here is what you need to add to the htaccess file:

Windows:

php_value include_path "C:/yourpath/mywebsite"

Linux:

php_value include_path "/yourpath/mywebsite"

2 Responses to "Set PHP Include path via .htaccess file"

"SHARING IS CARING"
  1. Vanessa says:

    I am very interested in learning how to do this. My particular reason is that I read an article on creating a private web page, and it sounds like I need to start by creating a .htaccess file, which I do not know how to do.

    That article says this will only work with Linux, but I don’t mind using either Linux or Windows, since I have them both on my computer. Whatever is easier (and/or more effective) in your opinion is what I will use.

    Is Apache the software I need to download in order to create a .htaccess file?

  2. eligeske says:

    Apache is actually the web server. Linux would be the operating system installed (similar to windows). Apache would be similar to IIS on windows.

    As long as where you are hosting your website is linux, 99% of the time they use apache. With that being said, you can use an .htaccess file by putting it in your root directory of your website.

Learning DHTMLX Suite UI

Learn the foundation of the DHTMLX Suite quickly while building a single page application with multiple components in harmony.

Popular post