-2

I tried this code on localhost:

<?php wp_redirect('https://google.com/'); exit; ?>

On localhost it works well.

As I upload this on live site, It's function wp_redirect does not work.

Thanks for your help.

Nirmohi
  • 128
  • 1
  • 10

1 Answers1

0

You should put this function at the top of the codes. I suggest you use init action for redirect page.

add_action('init', function(){
if( isset($_GET['exit']) ) {
wp_redirect('https://google.com/');
 exit;
}
});

this code put functions.php in your theme.

Vel
  • 9,027
  • 6
  • 34
  • 66
Mehrshad Darzi
  • 101
  • 1
  • 4
  • More info here [link]https://stackoverflow.com/questions/19587154/wp-redirect-is-not-working – Jamie_D Sep 14 '18 at 07:18
  • Thanks for your help. Your code working fine on online page. I add this code: `function app_output_buffer() { ob_start(); } // soi_output_buffer add_action('init', 'app_output_buffer');` and it works – Nol0019 Sep 14 '18 at 07:35