savage Posted January 31, 2013 Share Posted January 31, 2013 Hello sorry if this is incredibly beginner, it is my first post, and couldn't find anything / didn't know what to search for I have set up a navigation menu in "core/linkmenu.php" which shows my navigation links e.g. <a href="index.php">Home</a> and included it in the first directory page index.php with "<?php include("core/linkmenu.php"); ?>" so there is a link on the index page (index.php) and all pages in the same directory level to the navigation links found in core/linkmenu.php However in my subdirectories, if I try to use <?php include("../core/linkmenu.php"); ?> it will take me to /subdirectory/index.php. and thus return an error page. as the actual page is a directory higher. so what should I do to remedy this? as I would like only 1 page that holds the navigation links and not create different linkmenu pages for each subdirectory level. Thanks very much for reading and hope you can help me out Link to comment https://forums.phpfreaks.com/topic/273872-subdirectory-linking-issue/ Share on other sites More sharing options...
Jessica Posted January 31, 2013 Share Posted January 31, 2013 Your links need to be the full path. Either with the domain or just from the root folder. Link to comment https://forums.phpfreaks.com/topic/273872-subdirectory-linking-issue/#findComment-1409358 Share on other sites More sharing options...
savage Posted January 31, 2013 Author Share Posted January 31, 2013 ah yes that would work. thanks very much. However is that accepted practice? as if you were editing/testing offline using localhost root folder then you would have to change every link to the online server every time you wanted to upload editions Link to comment https://forums.phpfreaks.com/topic/273872-subdirectory-linking-issue/#findComment-1409359 Share on other sites More sharing options...
Jessica Posted January 31, 2013 Share Posted January 31, 2013 You either don't use the domain, or you set up the domain as a server variable. Link to comment https://forums.phpfreaks.com/topic/273872-subdirectory-linking-issue/#findComment-1409360 Share on other sites More sharing options...
savage Posted January 31, 2013 Author Share Posted January 31, 2013 ok not entirely sure what that means, but thanks for the reply and I will look into what you recommend Link to comment https://forums.phpfreaks.com/topic/273872-subdirectory-linking-issue/#findComment-1409393 Share on other sites More sharing options...
Jessica Posted January 31, 2013 Share Posted January 31, 2013 If index.php is in your webroot, the link should be "/index.php" Link to comment https://forums.phpfreaks.com/topic/273872-subdirectory-linking-issue/#findComment-1409394 Share on other sites More sharing options...
jcbones Posted February 1, 2013 Share Posted February 1, 2013 I always set up my paths in my constants. This way if you are changing directories, you only have to change it in one file to affect the whole site. Example: define('PATH',$_SERVER['DOCUMENT_ROOT']); define('SITE','http://' . $_SERVER['SERVER_NAME']); Link to comment https://forums.phpfreaks.com/topic/273872-subdirectory-linking-issue/#findComment-1409541 Share on other sites More sharing options...
savage Posted February 14, 2013 Author Share Posted February 14, 2013 sorry late reply. Thanks very much for your advice from both of you. Link to comment https://forums.phpfreaks.com/topic/273872-subdirectory-linking-issue/#findComment-1412444 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.