StevenOliver Posted February 24, 2019 Share Posted February 24, 2019 I have a directory in public WWW. The files throughout the directory have many PHP includes amongst themselves. For example, the file "registration.php" begins with require('../parameters.php'); The directory is complex, like this: /Public WWW directory/ /My_Directory parameters.php another_reg.php /app files.inc files2.inc /morefiles another.inc another2.inc /css mycss.css /pages config.php registration.php My question: I want the entire directory moved out of reach above the public WWW, but I want "registration.php" to go into the public WWW. How would I do that without breaking all the include paths? (I know the solution is probably a one-liner involving __DIR__ ... but I can't seem to code it so it works). Thank you!! Quote Link to comment https://forums.phpfreaks.com/topic/308376-moving-directory-keeping-paths/ Share on other sites More sharing options...
requinix Posted February 24, 2019 Share Posted February 24, 2019 Create an include file just above your WWW directory that will define some very basic things. It will always live just above the WWW directory. Always. Put in it something like const INCLUDE_DIR = "some path to find your new include directory"; You can put other commonly-needed things in there too. Or include other files. Whatever. registration.php will include it with require_once $_SERVER["DOCUMENT_ROOT"] . "/../the new include file.php"; then it can do things like require_once INCLUDE_DIR . "/files.inc"; or whatever. There are better approaches to this problem but they will require more significant changes. For now, this is enough. Quote Link to comment https://forums.phpfreaks.com/topic/308376-moving-directory-keeping-paths/#findComment-1564728 Share on other sites More sharing options...
StevenOliver Posted February 24, 2019 Author Share Posted February 24, 2019 " 15 hours ago, requinix said: There are better approaches to this problem....For now, this is enough. Thank you, I appreciate that you noticed this was just a temporary thing... so many files, and you're right I just needed a temporary fix. I gotta be careful though.... lots of my "temporary fixes" end up being permanent because I get too lazy to clean them all up :-) Quote Link to comment https://forums.phpfreaks.com/topic/308376-moving-directory-keeping-paths/#findComment-1564771 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.