Change url in php after reloading a page

大城市里の小女人 提交于 2020-01-10 06:08:27

问题


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


回答1:


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!';
    }

}


来源:https://stackoverflow.com/questions/9807229/change-url-in-php-after-reloading-a-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!