Block a specific url request

I probably have a plugin that makes a request to an URL slowly down my website. At the moment I'm still debugging the issue but, in the meantime, is there a way to prevent Wordpress to request this URL?

I know there's the rule define('WP_HTTP_BLOCK_EXTERNAL', true); but it actually blocks every request.

Topic request-filter urls Wordpress

Category Web


Like you suggested, use WP_HTTP_BLOCK_EXTERNAL to stop all external URL requests. And then use WP_ACCESSIBLE_HOSTS to set allowed URLs.

From the WP Codex, found on this page.

wp-config.php

define( 'WP_HTTP_BLOCK_EXTERNAL', true );
define( 'WP_ACCESSIBLE_HOSTS', 'api.wordpress.org,*.github.com' );

Block external URL requests by defining WP_HTTP_BLOCK_EXTERNAL as true and this will only allow localhost and your blog to make requests. The constant WP_ACCESSIBLE_HOSTS will allow additional hosts to go through for requests. The format of the WP_ACCESSIBLE_HOSTS constant is a comma separated list of hostnames to allow, wildcard domains are supported, eg *.wordpress.org will allow for all subdomains of wordpress.org to be contacted.

Note: This could have unintended consequences like potentially breaking plugins, auto updates, etc.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.