I am using two website on one domain like: www.example.com & www.example.com/site2. I want to know that on my site2, in my site2 their are 2 folders name folder1 and folder2 my index.php is in folder2 but the definition of methods defined in folder2 I am including the files through .htaccess but I am unable to get those files which are in folder1 and getting Error-500 and 400 on browser and I am using following lines but they are not working in .htaccess file

The line below works fine

RedirectMatch ^/$ http://www.example.com.pk/site2/views/

AllowOverride All
php_value include_path ".:/home/example/public_html/site2/system"
  • What you describe is a single web site - the first one is the root folder, and the second is a folder within the same site.
    – dunxd
    Commented Dec 21, 2010 at 12:10
  • Did you review your question at least for a time?
    – Ehsan
    Commented Dec 21, 2010 at 12:17
  • @Ehsan with 1 rep the review process is probably not what you'd expect :-)
    – Déjà vu
    Commented Dec 23, 2010 at 12:10

2 Answers 2


Are you trying to include your methods and classes for use by PHP? If so, you most likely want to use include() or require() functions within your PHP code rather than doing it through Apache.

I can't really tell from your question exactly what you are trying to achieve. If you really need to use Apache for your includes, please expand your question to give more details.

  • well yes i really need to use Apache, their are two folders name: "system" which have database layer which can interact with DB and second folder name: "views" which have all html, php files and sub-folders in php files or in sub-folders i want to just add this in php or in subfolders having php files: include ("database/db_call.php"); because previous path was defined in .htaccess Commented Dec 23, 2010 at 7:59
  • If you are including files which have php code in that must be executed, you need to use PHP include functions. You don't need to use Apache .htaccess or httpd.conf to achieve this. See the link I added to my answer for more info.
    – dunxd
    Commented Dec 23, 2010 at 9:15

Also, your current .htaccess file doesn't include files, it only sets the include path that php uses. So, imagine this file tree:

| - a
|   |- myphp.php
| - b
|   |- myinclude.extension

When you include in the php file myphp.php, normally you would do this:

<?php include('../b/myinclude.extension'); ?>

But after setting

AllowOverride All php_value include_path "root/b/"

you only need to type

<?php include('myinclude.extension'); ?>

but that really doesn't make a big difference doesn't it? Please read through the php.net pages about include, require and include_once, require_once.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .