jbmoyer Posted January 23, 2009 Share Posted January 23, 2009 ...not really a PHP question but, ... I have some pages that have ../../folder/page.html links, Is there a way to convert those URLs to the full path? At runtime? I know I can go into the code and by hand manually change them all but there is too many and thats not really a good option, so is there a "magical" way to use FSO or something similar to get the path for ../../ wherever they appear? Thank you... Quote Link to comment https://forums.phpfreaks.com/topic/142162-relative-urls/ Share on other sites More sharing options...
severndigital Posted January 23, 2009 Share Posted January 23, 2009 what would be the benefit of changing them?? doesn't the browser build the full path for you at runtime? if you would hard code them you would have a difficult time transporting your pages if you changed domain names or directory names. this way your code is very flexible. not trying to start an argument .. just asking the question Quote Link to comment https://forums.phpfreaks.com/topic/142162-relative-urls/#findComment-744698 Share on other sites More sharing options...
jbmoyer Posted January 23, 2009 Author Share Posted January 23, 2009 right it is very flexable and portable, but we have a webiste that is consuming some of our pages and whan they get consumed the images break, links break etc.... so if we could change ../../folder/page.html to http://www.domain.com/foldera/folderb/folder/page.html Any thoughts Quote Link to comment https://forums.phpfreaks.com/topic/142162-relative-urls/#findComment-744704 Share on other sites More sharing options...
Maq Posted January 23, 2009 Share Posted January 23, 2009 $_SERVER look at DOCUMENT_ROOT, that might help you. Quote Link to comment https://forums.phpfreaks.com/topic/142162-relative-urls/#findComment-744707 Share on other sites More sharing options...
PFMaBiSmAd Posted January 23, 2009 Share Posted January 23, 2009 A leading slash / on a relative URL makes it relative to the domain of the current URL. So /foldera/folderb/folder/page.html is probably what you need. DOCUMENT_ROOT is actually a file system path and does not have anything to do with forming URL's. Quote Link to comment https://forums.phpfreaks.com/topic/142162-relative-urls/#findComment-744714 Share on other sites More sharing options...
jbmoyer Posted January 23, 2009 Author Share Posted January 23, 2009 here is something simple, what about base href? Is that deprecated? should I not use it? Quote Link to comment https://forums.phpfreaks.com/topic/142162-relative-urls/#findComment-744723 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.