Note: having /home/laurexn109/domains/ in front of it is actually required for it to work.
How is it possible that neither of these, nor files hosted elsewhere work?
– http://subdomain.domain.com/wp-content/uploads/2017/07/song.mp3
– http://www.domain.com/public_html/subdomain/wp-content/uploads/2017/07/song.mp3
I found out that it has something to do with the url. The url returned by the first 3 lines of php above is exactly the same as the url that I see when I go to the Media Library in the Dashboard.
But when I use the attachment_url_to_postid function to get the id of the file and then use the get_attached_file function to get the url, it gives me a different url, one that actually works.
So my question now is:
Why doesn’t an url like this work?:
subdomain.domain.com/wp-content/uploads/2017/07/song.mp3
And why does an url like this work?:
/home/laurexn109/domains/domain.com/public_html/subdomain/wp-content/uploads/2017/07/song.mp3
(/home/laurexn109/domains/ is from the server my website is hosted on)