Jump to content

Relative URLs...


jbmoyer

Recommended Posts

...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...

Link to comment
https://forums.phpfreaks.com/topic/142162-relative-urls/
Share on other sites

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 :)

 

 

Link to comment
https://forums.phpfreaks.com/topic/142162-relative-urls/#findComment-744698
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/142162-relative-urls/#findComment-744704
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/142162-relative-urls/#findComment-744714
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.