Ganga U
Ganga U

Reputation: 61

Passing parameter in URL leads to 404 page in codeigniter?

I have tried the code for passing parameter in the URL but the system is considering it as parameter and leads to 404 error page

Below is the code I am using for the same

<a href="view_pre_read/1315">click here to go</a>

My system's htaccess code is:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /dashboard_new4/


RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]


RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

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

</IfModule>

<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

My routes.php has following code: $route['view_pre_read/(:num)'] = 'view_pre_read/index/$1';

controller is :

class View_pre_read extends CI_Controller {

    function index($tid){
            echo $tid;
            $this->load->view('pages/notopic',$data);

    }

}

Please help how to over come this. if i send only controller url like 'view_pre_read/' its finding the controller class. only thing is if i send parameter its going to 404 error.

Thanks and Regards raju

Upvotes: 0

Views: 1744

Answers (4)

developer avijit
developer avijit

Reputation: 99

<a href="<?php echo base_url()?>/view_pre_read/1315">click here to go</a>

Upvotes: 0

Ashish Kashyap
Ashish Kashyap

Reputation: 11

You are forgetting "index" i.e. method name in your class. Try this view_pre_read/index

Upvotes: 1

Sanith
Sanith

Reputation: 679

Try this <a href="view_pre_read/index/1315">click here to go</a> instead of <a href="view_pre_read/1315">click here to go</a>

The first url segment is class name (view_pre_read) & section one is function (index). The parameter you need to pass in third position.

Upvotes: 0

Ijaz Ahmed Bhatti
Ijaz Ahmed Bhatti

Reputation: 739

change this to

$this->load->view('pages/notopic',$data);

$this->load->view('pages/notopic/',$data); and bingo

Upvotes: 1

Related Questions