重定向在 Wordpress 中不起作用? [英] Redirection not working in Wordpress?

查看:51
本文介绍了重定向在 Wordpress 中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 wordpress 中使用以下代码进行重定向

I am using below code for redirection in wordpress

$currentPage = explode('?', $_SERVER ['REQUEST_URI']);
  $current_page_url = $currentPage[0];
 if($current_page_url == '/e-commerce')
    {
        header("Location : http://www.mysite.com/complete-e-commerce-solution",true);
    }

我在 header.php 中使用此代码,我正在重定向到第三方站点.这是问题吗?

I am using this code in header.php, i am redirecting to third party site.is that problem?

推荐答案

您需要在标头调用之后使用exit".但是,您可能会更好地使用 wordpress 的内置 wp_redirect 函数:

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;

使用 wordpress 函数允许插件过滤输入并清理输入(这里不太适用,只是很好的做法).

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

这篇关于重定向在 Wordpress 中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆