I am trying to use RESTful controller. Here is my Route.php
:
Route::resource(\'test\', \'TestController\');
Route::get(\'/\', function()
{
r
A NotFoundHttpException
exception in Laravel always means that it was not able to find a router for a particular URL. And in your case this is probably a problem in your web server configuration, virtual host (site) configuratio, or .htaccess configuration.
Your public/.htaccess should look like this:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
As you can see there is a condition in the first line IfModule mod_rewrite.c
, so if you don`t have mode_rewrite installed or enabled, all rewrite rules will fail and this
localhost/Test/public/
Will work fine, but not this:
localhost/Test/public/test
In other hand, this one should work too, because this is its raw form:
localhost/Test/public/index.php/test
Because Laravel needs it to be rewritten to work.
And note that you should not be using /public, your URLs should look like this:
localhost/Test/
This is another clue that your virtual host's document root is not properly configured or not pointing to /var/www/Test/public, or whatever path your application is in.
All this assuming you are using Apache 2.
I was getting the same error exception while one project was working but another project with same .htaccess file on same localhost was not working. Turns out since my project directory has capital letter in it, URL also should be capital for routing to work. localhost/minorweb/public/account was not working but localhost/minorWeb/public/account with W capital was working. so, if nothing seems to solve the problem, check your URL is matched with project directory with case.
In my scenario, the problem was I've used an extra prefix slash like:
Route::get('/plans', 'PayPalController@getPlansList')->name('paypal.plans');
instead of:
Route::get('plans', 'PayPalController@getPlansList')->name('paypal.plans');