0
votes

I'm facing a URI Routing problem that I'm sure someone here can help me solve. I've googled enough to make my brain freeze. Okay, here is the situation

CodeIgniter Version : 2.1.3

I've routed two pages in the application/config/routes.php

$route['sites/(:any)'] = 'profiles/professional';

$route['sites/(:any)/(:any)'] = 'profiles/professional/$1';

I've a controller named : Profiles

A Method inside Profiles :

public function professional(){

    $user = $this->uri->segment(3);

    $current_page = $this->uri->segment(4);

    switch ($current_page) {
        case 'about':
            $this->data['content'] = 'user_sites/about_view';
            break;
        default:
            $this->data['content'] = 'user_sites/home_view';
            break;
    }



    $this->load->view('my_view',$this->data);       
}

Now if I load

www.mysite.com/sites/some_user/

It loads just fine. And Routing works fine. (I've htaccess file to remove index.php )

But when I try to load

www.mysite.com/sites/some_user/about/

It wont load (blank page). However, the route is actually working. Because when I load

www.mysite.com/sites/index.php/some_user/about/

It loads using my switch in the controller.

So I think I've to add a line or two of code in my .htaccess file? Someone please help? My current .htaccess file looks like this

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

ModRewrite is ON too.

Thanks a lot in advance...

1
Try to echo this: $current_page = $this->uri->segment(4). What you got?sinisake
Shows nothing for "www.mysite.com/sites/some_user/about/" www.mysite.com/sites/index.php/some_user/about actually shows everything alright. So I think it should be a .htaccess fix?tintinboss
Anyone? with an answer?tintinboss

1 Answers

1
votes

I think you got a mistake in your count of segments and Your codecs looking the about keyword in segment 4 so it will find it in this URL www.mysite.com/sites/index.php/some_user/about

Note that here the index.php is not really the index page as it is after the sites controller and it is referring g to it as a segment (therefor it is not an htaccess. Issue)

If you remove the index.php www.mysite.com/sites/some_user/about

About is located in segment number 3