在重新加载网页后更改php中的网址 [英] Change url in php after reloading a page
本文介绍了在重新加载网页后更改php中的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的首页网址如下所示:
http:// localhost / mediabox / home / box / 12
当用户点击该链接时,我在主页上有一个语言链接,我将该语言ID作为查询字符串,网页重新加载并将网址转换为
http:// localhost / mediabox / home / box /?bid = 12& ; ln = 2
我想使用新语言重新加载页面,但不想更改我的网址,即我要的网址为
http:// localhost / mediabox / home / box / 12
页面加载后
一些gud想法
感谢
解决方案
VIEW
< a href =<?php echo site_url('home?language = indonesian');?>>印度尼西亚语< / a>
CONTROLLER
class Home extends CI_Controller {
public function index()
{
$ language = $ this-> input-> get('language');
if($ language){
//将代码放在这里
//现在可以设置会话
$ this-> session- > set_userdata('language',$ language);
redirect('home');
}
if($ this-> session-> userdata('language'))
{
var_dump($ this-> session-> ; userdata('language'));
}
echo'Hello World!';
}
}
My home page url looks like this
http://localhost/mediabox/home/box/12
I have a link of language on home page when a user clicks on that link i am sending that language id as query string , the page reloads and the url converts to
http://localhost/mediabox/home/box/?bid=12&ln=2
I want to reload the page with the new language but don't want to change my url i-e I want my URL to be
http://localhost/mediabox/home/box/12
after the page loads
How it is possible please me some gud ideas Thanks
解决方案
VIEW
<a href=<?php echo site_url('home?language=indonesian');?>>Indonesian language</a>
CONTROLLER
class Home extends CI_Controller {
public function index()
{
$language = $this->input->get('language');
if($language){
// Put your code here
// Now u can set session
$this->session->set_userdata('language', $language);
redirect('home');
}
if($this->session->userdata('language'))
{
var_dump($this->session->userdata('language'));
}
echo 'Hello World!';
}
}
这篇关于在重新加载网页后更改php中的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文