简体   繁体   中英

Codeigniter pagination url use query string

Default library Pagination of Codeiniter use segment with url like this : products/list/1

But , i want config paging use query string.

I have try enable $config['page_query_string'] = TRUE but result is products/list&page=1

Then , it is not format of query string, i want link paging is : products/list?page=1

Please help me ;(

You need to follow these steps:

  1. In application/config/config.php set:

    $config['enable_query_strings'] = true;

  2. Again in application/config/config.php set:

    $config['uri_protocol'] = "PATH_INFO";

  3. Change your .htaccess to remove the ? (if present) in the rewrite rule:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]

Please define base url like

$config['base_url'] = 'your path';
$config['page_query_string'] = TRUE;

So your query string is append with above base url like 'path?query_string_of_pagination'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM