The Slim Framework support forum has moved to http://discourse.slimframework.com. This Tender forum is no longer maintained or monitored.

/categories route gives me always 404

luca's Avatar

luca

30 Dec, 2011 11:07 AM

Hello,

I'm a newbie to REST and the Slim framework, so I have a very dummy question I think!
I'm building a really easy PHP webservice that exposes some tables of a MySQL DB.
One table is called "categories", so I have a route "/categories" that returns an XML list of the categories inside that table.
I have got problems just with the route.

This is my index.php running on PHP 5.3.8 on my website (just a test):

<?php

require 'Slim/Slim.php';

$app = new Slim();

$app->get('/categories', function () {
    echo "Categories test!";
});

$app->run();

?>

Well, I always get 404 with this script. If I simply change the route to, say '/category', or "/products", it runs well.
Is the "/categories" route invalid? Why?

Thanks all,
Luca

  1. 1 Posted by luca on 30 Dec, 2011 01:51 PM

    luca's Avatar

    I made some other tests and I got the error with other routes also.
    I guess it's a .htaccess problem on my hosting space, I'm investigating.

    Any suggestions?
    Thanks
    Luca

  2. Support Staff 2 Posted by Josh Lockhart on 30 Dec, 2011 02:17 PM

    Josh Lockhart's Avatar

    The problem seems like it would be a .htaccess problem. I think you're right. Try to rule out .htaccess issues first. I'm fairly certain it isn't a Slim issue, but I'll check after work today just to make sure. Will post again this evening.

    Josh

  3. 3 Posted by luca on 30 Dec, 2011 02:48 PM

    luca's Avatar

    Ops. excuse me if I sent the same answer many times. You're moderating I guess :-P

  4. 4 Posted by luca on 30 Dec, 2011 08:50 PM

    luca's Avatar

    Thank you lots for your answer, Josh.
    I made some other tests, but unfortunately I'm not an Apache expert :(
    I can't figure it out since it seems to "like" some urls and "dislike" others... for instance I can't make /categories and /shops work, while /payments works well... a really strange behaviour I think!

    I tried not to use .htaccess by renaming it to htaccess.txt, then I used the no-rewrite URL by calling:

    http://www.mydomain.org/index.php/categories

    I still get a 404, but with a "No input file specified." error as the body.
    Hope you'll find something to suggest to me this evening, many thanks :)

    Luca

  5. Support Staff 5 Posted by Josh Lockhart on 31 Dec, 2011 08:46 PM

    Josh Lockhart's Avatar

    Cannot duplicate on my end. Marking this as resolved. But please leave another comment here if you are still unable to get it working.

  6. Josh Lockhart closed this discussion on 31 Dec, 2011 08:46 PM.

  7. luca re-opened this discussion on 03 Jan, 2012 04:47 PM

  8. 6 Posted by luca on 03 Jan, 2012 04:47 PM

    luca's Avatar

    Thank you for your answer, Josh.
    I keep on investigating.

    Anyway, I tried to use also the "no-rewrite" URL by deleting the .htaccess file and calling URLs like http://www.mydomain.org/index.php/categories.

    I still get a 404, but with a "No input file specified" error as the body.
    So it seems I have problems also without using URL rewrite.

    Any ideas?

    Thank you much,
    Luca

  9. 7 Posted by Guillaume on 21 Feb, 2012 03:45 PM

    Guillaume's Avatar

    Did you enable mod_rewrite module on apache2 ?

    Did you modify the AllowOverride Options to accept .htaccess modification ?

  10. Andrew Smith closed this discussion on 01 Aug, 2012 12:45 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac