Why is the folder structure on the server not relevant when dealing with relative paths in HTTP requests?

When dealing with relative paths in HTTP requests, the folder structure on the server is not relevant because the paths are relative to the current URL of the request, not the file structure on the server. This means that the paths specified in the requests will be resolved based on the URL of the request, regardless of where the files are located on the server.

// Example of using a relative path in an HTTP request
$baseUrl = "http://example.com";
$requestPath = "/api/data";
$requestUrl = $baseUrl . $requestPath;

// This will result in the full URL: http://example.com/api/data
echo $requestUrl;