Redirection not working in Wordpress?

前端 未结 2 1199
野性不改
野性不改 2021-01-22 10:00

I am using below code for redirection in wordpress

$currentPage = explode(\'?\', $_SERVER [\'REQUEST_URI\']);
  $current_page_url = $currentPage[0];
 if($current         


        
相关标签:
2条回答
  • 2021-01-22 10:49

    Any chance of getting /e-commerce from $currentPage[0]? The '/e-commerce' looks more like something that would be found at $currentPage[1].

    0 讨论(0)
  • 2021-01-22 10:59

    you need to follow the header call with an 'exit`. However, you might be better using wordpress's inbuilt wp_redirect function:

    wp_redirect("Location : http://www.mysite.com/complete-e-commerce-solution");
    exit;
    

    Using wordpress functions allows plugins to filter the input and sanitises the input (not so applicable here, just good practice).

    0 讨论(0)
提交回复
热议问题