Search code examples
php.htaccesshttp-redirectdirectory-tree

.htaccess and php - need instructions with inclusion


So this is my site structure:

  • public_html
    • .htaccess
    • test-dir
      • home.php
    • includes-dir
      • file.php

And here's the code in home.php: require"./includes-dir/file.php"; But this fails. How to require file.php in home.php correctly? I need this becauase my .htaccess file redirects domain.com to domain.com/test-dir. Thanks in advance!


Solution

  • You can make use of the dirname in PHP to get the current file location. http://www.php.net/dirname

    require_once dirname(__FILE__) . '/../includes-dir/file.php';