Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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