Reputation: 5758
I am very confused as to why this is happening but here is the issue guys. Basically I am building an app using laravel4
I want to go to this URL
http://app.tld/books
However I get this error every time:
404: The requested URL /books was not found on this server.
However in my routes.php
file I have the route defined:
Route::get('/books', 'BookController@index');
I also have a view and relevent method in Controller
:
public function index(){
$books = Book::all();
return View::make('book.index')->with('books', $books);
}
Upvotes: 2
Views: 344
Reputation: 4117
From the comments we gather that it was an Apache issue, not a Laravel issue (mod_rewrite
wasn't enabled -- kudos to @watcher), and I'm glad you sorted it out.
For future reference, it seemed likely to be an Apache issue because Laravel throws PHP exceptions on undefined routes, namely a Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
. If you have debug
set to true
you'll get a neatly styled stack trace with code highlighting and server/request data, if not you'll get a neatly styled "Whoops, looks like something went wrong." message. If, on the other hand, you get a white screen with Times New Roman messages like "404: The requested URL /books was not found on this server.", Laravel isn't even starting up.
As the comments on your question show, there are many other clues which will tell you that it's not your Laravel routes, though from the code you posted and even the title of the question, you seemed to had narrowed it down to routes, which probably had you looking in the wrong place for a while.
Upvotes: 1