Pass external url trough if page not found
-
Hello,
Is it possible to pass a external content form other domain if a 404 happens?
We installed a wordpress site (www.woefkesranch.fr) but the old content should be visible too (fr.woefkesranch.be). So when you visit https://www.woefkesranch.fr/navigation/images/facebook-fr.jpg and not found, it should look at https://fr.woefkesranch.be/navigation/images/facebook-fr.jpg but without changing the domain
I already found this, http headers aren’t pass.function wpd_do_stuff_on_404(){ if( is_404() ){ // do stuff global $wp; $current_url = home_url(add_query_arg(array(),$wp->request)); //set $url to what's needed $url = str_replace('www.woefkesranch.fr','fr.woefkesranch.be',$current_url); $response = wp_remote_get($url); $response_code = wp_remote_retrieve_response_code( $response ); //echo $response_code; if ($response_code == 200){ //status_header(200); echo wp_remote_retrieve_body( $response ); die(); } } } add_action( 'template_redirect', 'wpd_do_stuff_on_404' );
Any suggestions?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Pass external url trough if page not found’ is closed to new replies.