Php 更改地址栏中的url

Php 更改地址栏中的url,php,jquery-mobile,Php,Jquery Mobile,我有两个模块,tempalate和youraccount 在我的模板模块中有一个名为customer_panel的视图文件 这是文件customer_panel.php的内容 <a href="<?= base_url() ?> youraccount/logout "class =" ui-shadow ui-btn ui-corner-all ui-btn-icon-left ui-icon-action ui-btn-b "> Logout </a>

我有两个模块,tempalate和youraccount

在我的模板模块中有一个名为customer_panel的视图文件 这是文件customer_panel.php的内容

<a href="<?= base_url() ?> youraccount/logout "class =" ui-shadow ui-btn ui-corner-all ui-btn-icon-left ui-icon-action ui-btn-b "> Logout </a>
我的基本url地址是localhost/mywebsite

当我点击注销按钮时,它确实指向了我的主页 地址栏中的链接是localhost/mywebsite/yourcount/logout


当我单击注销按钮时,我的地址栏是否可以转到localhost/mywebsite?

因为您没有发布函数的代码
redirect()
我无法明确回答该函数

重定向(base_url())

我的建议是替换自定义的
redirect()
函数,改用php
header()
函数:

header('Location: ' . base_url());

更新
在使用CodeIgniter中的
redirect()
命令之前,您需要加载模块:

如果这不起作用,你可以试着改变现状。 请尝试两种方法:

redirect(base_url(), 'location');
// or
redirect(base_url(), 'refresh');

我试着用它,但还是不能用。我将尝试查找更多关于header()的参考资料。
header()
只有在以前没有输出的情况下才有效。您是使用php框架还是自己编写代码?如果不是框架,请粘贴
redirect()
函数的代码。我使用codeigniter框架。。我正在制作它的手机版。。当我在网站上打开jQuery Mobile时,它运行良好。。他的直接链接指向我想要的localhost/mywebsite,但如果它使用移动浏览器打开,它的页面将指向localhost/mywebsite,它位于我的网站的主页。。但地址栏中的地址不变,请保留localhost/mywebsite/yourcount/logout$http='http'。((isset($_服务器['HTTPS'])和&$_服务器['HTTPS']='on')?'s':''。:/'$newurl=str_replace(“index.php”,”,$_服务器['SCRIPT_NAME'])$配置['base_url']=“$http”$_服务器['SERVER_NAME']。"" . $新网址;
$this->load->helper('url');
redirect(base_url());
redirect(base_url(), 'location');
// or
redirect(base_url(), 'refresh');