Okay so I made a configuration file. Also I am testing this out with Xampp. $config = parse_ini_file("config/global.ini"); $tester = parse_ini_file("config/tester.ini"); $serverName = $_SERVER['SERVER_NAME']; //~ $serverName = $_SERVER['DOCUMENT_ROOT']; if (isset($tester[$serverName])) { $serverName= $tester[$serverName]; } Code (markup): It works across the board however, if a file is in a subdirectory, the menu hyperlink will start in the same folder then look for $serverName. The file is in: "websites name"/tuts/lib/a/sideflow.php Code (markup): it links there just fine, the CSS does not show and the menu links look like: http://localhost/zerocore/work/www."websites name".com/tuts/lib/a/students.php Code (markup): it should not have the (tuts/lib/a) when inside the sideflow.php file, this is for the menu across the site. What am I doing wrong?
I tend to make all hyperlinks start at the document root - that way they always work so regardless of the folder I'm in the link will always be /folder/subfolder/page it makes life a lot easier.
see the issue with that is: <a href="/students.php" class="ex2">Students</a> (this is inside the include "header.php") Code (markup): it goes to: localhost/students.php Code (markup): I am using Xampp on the live server I have a Dev directory, that method works. However what about localhost Xampp testing?
I'm not sure the Xampp matters. You have a site you are testing and it's in a subfolder in a subfolder etc. In your config file "declare" a variable that holds what you think the root is, ie not localhost but "/localhost/zerocore/work/www."websites name".com/" and put that at the beginning of every hyperlink. then when the site goes live and onto proper hosting you just have to change the value of that declared variable
"/localhost/zerocore/work/www."websites name".com/" Code (markup): That only shows in Xamppp http://www."websites name".com/tuts/lib/a/students.php Code (markup): shows on the live site when I click on the students link
I do not think I am getting my problem properly across. see the side flow is two directories under the root. Everything else is inside root pretty much. so the link above to go to students.php is: <a href="/students.php" class="ex2">Students</a> Code (markup): found inside an include "header.php" which is in the root directory. It goes to students.php everywhere, however, inside sideflow.php which is in directory: /tut/lib/a/sideflow.php if you click on it, the result is: www."my website".com/tut/lib/a/students.php (THIS IS AN ERROR 404, STUDENTS.PHP IS LOCATED AT: WWW."MY WEBSITE".COM/STUDENTS.PHP Code (markup):
I think what Sarah is trying to say, create a file, ex: definitions.php (include the file in all files, or in a shared file if you have any, ex: dbconnect, header, template, etc.. that is already included in all files). In it place: <?php // Different set of configs if you are on localhost or live if ($_SERVER['HTTP_HOST'] == 'localhost') { define('APPLICATION_URL', 'http://localhost/site.com'); define('APPLICATION_PATH', '/localhost/zerocore/work/www.site.com/'); } else { define('APPLICATION_URL', 'http://www.site.com'); define('APPLICATION_PATH', '/var/zerocore/work/www.site.com/'); } PHP: Then anywhere you create a link, append the URL as so: <a href="<?php echo APPLICATION_URL;?>/students">Link</a> Code (markup):
[RESOLVED] YAY! ^-^ Thank you soooooo much ThePHPMaster, that resolved my issue across the board. It functions on localhost and when I load it into development. If it works in dev it will work when I switch it over to production. Thank you Thank you Thank you.