MysticKnight Posted January 25, 2020 Share Posted January 25, 2020 How can I use an include file that has a list of links in any directory at my website without breaking those links? You can see it in action here... The links in this directory work... https://www.billelgin.com/primary-directory/ The links in this directory (being created from the same include file) do not work... https://www.billelgin.com/primary-directory/subsection-one/ Obviously the problem is the include file is being called from different directories, so it's breaking the relative path links in the include file, but what can I do to fix it? You can download the example directory structure here... https://www.billelgin.com/EXAMPLE.zip Quote Link to comment https://forums.phpfreaks.com/topic/309930-easy-question-i-hope-php-include-file-with-links/ Share on other sites More sharing options...
kicken Posted January 25, 2020 Share Posted January 25, 2020 Use root-relative links. <a href="/primary-directory/subsection-one/">Subsection One</a> The leading slash means the link is relative to the root of the domain name so it doesn't matter which directory you're in. Quote Link to comment https://forums.phpfreaks.com/topic/309930-easy-question-i-hope-php-include-file-with-links/#findComment-1573803 Share on other sites More sharing options...
MysticKnight Posted January 25, 2020 Author Share Posted January 25, 2020 (edited) I swear I tried that. At least I thought that I did. But guess what, I made the change that you suggested and it's working perfectly. I uploaded the updated include file in case anyone else wants to see it working now. I can't tell you how much I appreciate it. Thank you! Edited January 25, 2020 by MysticKnight Quote Link to comment https://forums.phpfreaks.com/topic/309930-easy-question-i-hope-php-include-file-with-links/#findComment-1573804 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.