Hello All, Happy New Year 🙂 .In this quick article I will show, how to allow external url/host in wordpress.Recently i was working with wordpress for getting data from external feed url.
So, When I tried to access data from same domain,it was working fine but when i tried to access data from other domain/host, I got following error:
WP HTTP Error: A valid URL was not provided
I googled to get solution for above error in wordpress and what does it mean. This error occur because by default external urls are disabled in wordpress for security reason.So you need to allow external host/domain explicitly using following line of code into your
functions.php file or your plugin’s main file:
Here,I have used
http_request_host_is_external filter which is used to check HTTP request is external or not.In condiiton pass your external domain you want to allow.
So that’s it for now from my side. Hope this article will be useful to someone.