Question

Can someone tell me, where the issue is ??

This is my controller

class Support extends CI_Controller {
    public function __construct()
    {
        parent::__construct();
        $this->load->model('support_model');
        $urlarray = array("index","delete");
        if(!in_array($this->uri->segment(2),$urlarray)){
            $this->viewticket($this->uri->segment(2));
        }
    }

    public function viewticket($id){
        if(!empty($id)){
            $this->load->view('templates/logged_header');       
            $this->load->view('support/view');
            $this->load->view('templates/footer');
        }
    }
}

Here is my routes.php

$route['default_controller'] = "welcome";
$route['benefits'] = 'welcome/benefits';
$route['faqs'] = 'welcome/faqs';
$route['distributors'] = 'welcome/distributors';
$route['contact'] = 'welcome/contact';
$route['purchase'] = 'welcome/purchase';

//login routes
$route['login'] = 'login/index';
$route['logout'] = 'login/logout';

$route['404_override'] = '';

localhost/ciproj/support/hello-world gives me 404 Page Not Found error

If I use exit; after $this->load->view('templates/footer');, the page is showing me blank page.

I don't have anything in routes related to support and every other method is working Is there anything that i'm missing in routes ??

Thanks for the help.

Was it helpful?

Solution

Judging the title, first of all check if your server is running PHP using CGI/FastCGI or not (you could simply check that by phpinfo()).

If so, change the following in config.php:

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

Back to the topic, you could achieve that by using the single-line route below within your routes.php file:

$route['support/(?!index)(?!delete)(:any)'] = "support/viewticket/$1";

And remove these lines from your __construct method:

$urlarray = array("index","delete");
if(!in_array($this->uri->segment(2),$urlarray)){
    $this->viewticket($this->uri->segment(2));
}

Let me know how it works.

OTHER TIPS

Since the above answer did not work for me, I just added this function in my default_controller, and it worked.

    public function __construct() {
    parent::__construct();
    $this->load->helper('url');
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top