Category Archives: Projects

PHP: Relative URL to Absolute URL

Recently, I was working on a project and I needed to convert the relative URLs to their absolute URLs. An absolute URL such as “http://www.example.com/image.jpg” but mostly written as only “image.jpg” (relative URL) on the web pages. Web browser creates a complete URL using this relative URL and base URL. The base URL, must be absolute and it is often the URL of the web page containing the relative URL.

Now, if you need to access a file whose relative URL and base URL are known, you must combine them to create an absolute URL.
Continue reading