I am trying to create Admin controllers in the default controller folder. I have created "admin" folder in the "controller" folder.
In the routes file:
Route::get('/admin', 'admin/AdminController@showAdminIndex');
AdminController.php file:
namespace Admin;
class AdminController extends \BaseController {
public function showAdminIndex()
{
return "Hello World";
}
}
I get an error on the browser:
403 Forbidden
What went wrong?
The problem is that you have an
admin
subfolder in thepublic
directory. The.htaccess
that ships with Laravel only boots the application if no directory or file exists at the requested URI (that's why CSS and other assets still work)You basically have two options here:
Rename either one, the route or the folder. If
public/admin
is for assets you could put it inpublic/assets/admin
for example.Change your
.htaccess
to not ignore folders for rewritingLike: