.htaccess and php - need instructions with inclusion

79 views Asked by At

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!

2

There are 2 answers

0
Derek On BEST ANSWER

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';

0
AudioBubble On

I think you may be after this:

require_once dirname(FILE) . '/../path to file.php';