Faced a task, there are 2 identical sites on wordpress , one database, the only difference is that the first site has access to the Internet, and the other is deployed locally, one domain www.example.ru another example.local, as in principle can I replace links if the local version does not have access to the Internet? I try this:
function checkURL($url){ $domain = get_bloginfo('url'); $handle = curl_init($url); curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE); /* Get the HTML or whatever is linked in $url. */ $response = curl_exec($handle); /* Check for 404 (file not found). */ $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE); if($httpCode == 404) { $url = str_replace($domain, 'example.local', $url); return $url; /* Handle 404 here. */ } else { return $url; } curl_close($handle); wp_die(); } And I make this check for each link on the site, but the problem is that because of this the site loading time increases greatly, how can you solve it differently?