Laravel Group Route Issue
I'm using this code to implement admin area routes but Route::get('/',...)
doesn't work, it seems I should use anything other than /
in get
,otherwise laravel doesn't load view when I browse to mysite/admin/
.
Route::group(['prefix' => 'admin', 'namespace' => 'admin', 'as' => 'admin'], function() {
Route::get('/', function() {
return view('backend.index');
});
Route::resource('post', 'PostController');
});
UPDATE: there is an admin
folder in public
that is public/admin
. It seems Laravel open this directory instead of going through the route !
is it normal ?
does public folder structure has priority to Route::get()
?
Answer
If you have admin
folder inside public
folder it's normal that this directory content will be displayed but it's not Laravel issue.
If you look in public/.htaccess
you have there something like this:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
so if directory or file exists in public
directory Laravel will not launch application but server will display this directory or this file. This is what should be done, because if there wouldn't be such rule no CSS files, JavaScript files or images could be displayed.
What you should do is either change directory name in public
folder from admin
to something else (and then make changes in your code to reflect this change) or change admin
route to something else
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?