I am composing a internet crawler in php. Provided a present URL, and selection of web links to absolute, relative, and also root URLs, how would I recognize the fully-qualified URL for each link?

For example, i let"s say i am crawling the URL:

http://www.example.com/path/to/my/file.htmlAnd the array of links that the webpage includes is:

array( "http://www.some-other-domain.com/", "../../", "/search",);How would certainly I recognize the fully-qualified URL for each of those links? The result I am looking for in this instance would be, respectively:


You are watching: When do you need to use a fully qualified url in a hyperlink


I think the easiest method is to use a library like this:http://www.electrictoolbox.com/php-resolve-relative-urls-absolute/

Examples indigenous the link:

url_to_absolute("http://www.example.com/sitemap.html", "aboutus.html");resolves to http://www.example.com/aboutus.html


url_to_absolute("http://www.example.com/content/sitemap.html", "../images/somephoto.jpg");resolves to http://www.example.com/images/somephoto.jpg


Thanks because that contributing solution to stack Overflow!

Please be certain to answer the question. Carry out details and also share her research!

But avoid

Asking for help, clarification, or responding to other answers.Making statements based on opinion; earlier them up with recommendations or an individual experience.

To discover more, check out our advice on writing an excellent answers.

post Your price Discard

By clicking “Post your Answer”, girlfriend agree come our regards to service, privacy policy and also cookie plan

Not the answer you're looking for? Browse various other questions tagged php html url anchor href or questioning your own question.


site architecture / logo design © 2021 ridge Exchange Inc; user contributions license is granted under cc by-sa. Rev2021.9.17.40238

See more: What Common Kitchen Item Is Made Up Of Sodium And Chlorine Atoms ?

Stack Overflow works finest with JavaScript allowed

your privacy

By click “Accept every cookies”, you agree stack Exchange have the right to store cookie on your device and disclose info in accordance through our Cookie Policy.