I am currently using an index.php to include another file , it structure like:
root / index.php
/ new/ index.php
And I use
<?php
require_once("new/index.php");
?>
the problem is , all paths in it are wrong. As all paths are based on new/index.php , when i include it, all paths changes to based on index.php. Are there any way to let the outsider visit index.php but at the same time my actual code is stored in new/ folder? Thanks
Are you talking about something like
If so, use a slash to get to the url root and then use the full path from there like
Otherwise your urls can be messed up easily.
Change current directory using
chdir
function.include with an absolute path
require_once(dirname(__FILE__) . "/filename.php");
I'm not quite sure what you're asking, but if you want to include a file relative to your root, this is my solution: