1

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:

  • I don't have identical functions named user
  • No Controller named user
  • No library, helper named user

What could it be?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the info! I see the benefit of using the last slash. I'm confused because renaming the user method works in both browsers slash or no slash
What do you mean? If you rename from user to, lets say, banana it works?
I'm sorry, I just corrected my answer, as the top bit was wrong. But still, the answer for "why it works on Chrome but no on FF" still valid. You should check your routes.php file. This might help: codeigniter.com/forums/viewthread/94028

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.