Pagination in Codeigniter returns error
<p>My problem is that pagination is not working, its perfectly shows the number of pages &lt;&lt; 1 2 3 >> etc... but when I tried to go on page 2 then it gives me an error like:    </p>

<pre><code>The requested URL /mysite/welcome/index/2 was not found on this server.
</code></pre>

<p>Here is my Model called: <strong>Country.php</strong></p>

<pre><code>&lt;?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Country extends CI_Model
{
public function __construct() {
    parent::__construct();
}

public function record_count() {
    return $this-&gt;db-&gt;count_all("news");
}

public function fetch_countries($limit, $start) {
    $this-&gt;db-&gt;limit($limit, $start);
    $query = $this-&gt;db-&gt;get("news");

    if ($query-&gt;num_rows() &gt; 0) {
        foreach ($query-&gt;result() as $row) {
            $data[] = $row;
        }
        return $data;
    }
    return false;
   }
}
</code></pre>

<p>Here is my Controller which shows the news on the page, and the pagination, but unfortunately as I said when I try to go for page 2 then it returns an error message.</p>

<p>My Controller called <strong>Welcome.php</strong></p>

<p>

<pre><code> class Welcome extends CI_Controller {

/**
 * Index Page for this controller.
 *
 * Maps to the following URL
 *      http://example.com/index.php/welcome
 *  - or -
 *      http://example.com/index.php/welcome/index
 *  - or -
 * Since this controller is set as the default controller in
 * config/routes.php, it's displayed at http://example.com/
 *
 * So any other public methods not prefixed with an underscore will
 * map to /index.php/welcome/&lt;method_name&gt;
 * @see https://codeigniter.com/user_guide/general/urls.html
 */

public function __construct()
{
    parent::__construct();
    $this-&gt;load-&gt;model('news_model');
    $this-&gt;load-&gt;helper('url_helper');
    $this-&gt;load-&gt;model("Country");
    $this-&gt;load-&gt;library("pagination");
}


public function index()
{
    $config = array();
    $config["base_url"] = base_url('') . "welcome/index";
    $config["total_rows"] = $this-&gt;Country-&gt;record_count();
    $config["per_page"] = 2;
    $config["uri_segment"] = 3;

    $this-&gt;pagination-&gt;initialize($config);

    $page = ($this-&gt;uri-&gt;segment(3)) ? $this-&gt;uri-&gt;segment(3) : 0;
    $data["results"] = $this-&gt;Country-&gt;
        fetch_countries($config["per_page"], $page);
    $data["links"] = $this-&gt;pagination-&gt;create_links();

    $data['news'] = $this-&gt;news_model-&gt;get_news();
    $data['title'] = 'News archive';

    $this-&gt;load-&gt;view('index', $data);

}

public function view($slug = NULL)
{
    $data['news_item'] = $this-&gt;news_model-&gt;get_news($slug);

    if (empty($data['news_item']))
    {
            show_404();
    }

    $data['title'] = $data['news_item']['title'];

    $this-&gt;load-&gt;view('view', $data);
}
}
</code></pre>

<p>The routes are the default one</p>

<pre><code> $route['default_controller'] = 'welcome';
</code></pre>

<p>Also I can see my news and pagination on the homepage:</p>

<pre><code>localhost/mysite
</code></pre>

<p>I hope I was clear, please help me out why the pagination is not working.</p>

<p>Thanks for your kind help.</p>