/categories route gives me always 404
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
2 Posted by luca on 30 Dec, 2011 01:51 PM
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
Support Staff 3 Posted by Josh Lockhart on 30 Dec, 2011 02:17 PM
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
4 Posted by luca on 30 Dec, 2011 02:48 PM
Ops. excuse me if I sent the same answer many times. You're moderating I guess :-P
5 Posted by luca on 30 Dec, 2011 08:50 PM
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
Support Staff 6 Posted by Josh Lockhart on 31 Dec, 2011 08:46 PM
Cannot duplicate on my end. Marking this as resolved. But please leave another comment here if you are still unable to get it working.
Josh Lockhart closed this discussion on 31 Dec, 2011 08:46 PM.
luca re-opened this discussion on 03 Jan, 2012 04:47 PM
7 Posted by luca on 03 Jan, 2012 04:47 PM
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
8 Posted by Guillaume on 21 Feb, 2012 03:45 PM
Did you enable mod_rewrite module on apache2 ?
Did you modify the AllowOverride Options to accept .htaccess modification ?