CyberJunkie
CyberJunkie

Reputation: 22684

php URL segment goes unexpected to index

This is weird... I'm using the MVC pattern in php (codeigniter) to display a user's created categories. The URL pointing to a user's categories is

http://mysite.com/categories/user

This works in the Google Chrome browser but if Firefox it takes me to the index. Adding a trailing slash...

http://mysite.com/categories/user/

...takes me to the correct destination in both browsers. Also renaming the user controller works.

Inside controller

function user()
{
        $data['query'] = $this->Category_model->read_all_user_categories();
        $this->load->view('categories/read/user_categories', $data);    
}

The Model just returns a query.

What typically causes this behavior? I looked in all my files and can't find the culprit.

Crossing out possible causes:

What could it be?

Upvotes: 1

Views: 140

Answers (1)

dmmd
dmmd

Reputation: 3009

I just checked CI's docs, and:

The "index" function is always loaded by default if the second segment of the URI is empty.

Sorry for the mistaken information.

The sentence below is still valid (confirmation: http://wordpress.org/support/topic/links-to-wordpress-post-tabs-pages-must-have-trailing-slash)

The reason that it works on Chrome but not on Firefox, is due to Chrome's behavior of removing the last slash when submitting the request.

Upvotes: 2

Related Questions