I got the following error when the file is included.
Warning: require(home2/myusername/public_html/inc/config.php)
[function.require]: failed to open stream: No such file or directory in
/home2/myusername/public_html/inc/bootstrap.php on line 32
Fatal error: require() [function.require]: Failed opening required
'home2/myusername/public_html/inc/config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in
/home2/myusername/public_html/inc/bootstrap.php on line 32
It works fine in my local host running on a Windows PC. But I got this error when I uploaded files on my shared hosting server, which is CentOS.
home2/myusername/public_html/index.phpturns on /inc/bootstrap.php, which then tries to turn on /inc/config.php. The file config.phpexists on the server. home2/myusername/public_html/returned by function getcwd().
Below are the first few lines of code in bootstrap.php that cause the error.
define('APP_DIR', 'app');
if( !defined('APP_ROOT') ){
$APP_ROOT = trim(getcwd(), '/').'/';
if(isset($_GET['bootstrap'])) $APP_ROOT .= APP_DIR . '/';
define('APP_ROOT', $APP_ROOT);
}
if( !defined('ROOT') ){
$ROOT = str_replace(APP_DIR, '', trim(APP_ROOT, '/'));
if( strrpos($ROOT, '/') != strlen($ROOT)-1 ) $ROOT .= '/';
define('ROOT', $ROOT);
}
define('INC', ROOT.'inc/');
require INC . 'config.php';
I have a Rewrite's URL /public_html/.htaccess.
RewriteRule ^index.php$ index.php?bootstrap [L]
So when I browse example.com/index.php, it texted to example.com/index.php?bootstrap. This I got an error.
Here is my directory structure:
/public_html/
|__ inc
| |__ bootstrap.php
| |__ config.php
|__ .htaccess
|__ index.php <--- I'm browsing this
, . require 'inc/bootstrap.php index.php .