Reputation: 923
I have admin
subfolder in the public
folder, but I want to define the specific response on mywebsite.loc/admin
. Currently, if to input mywebsite.loc/admin
, it will be next response:
However I has the routes definition for admin
:
Route::group(['prefix' => 'admin', 'middleware' => 'auth'], function(){
Route::get('/', [
'as' => 'AdminTop',
'uses' => //Admin\AdminController@renderTopPage'
function(){
dd('ok');
}
]);
});
How I can make it work?
Upvotes: 5
Views: 1863
Reputation: 2111
If you create any folder in public and you want to use this folder as a route then you need to add your index.php which is useful for understanding this folder as a root.
For example, you create one folder in public/admin now you copy your public/index.php file into your admin folder and change two line in this index.php file
require __DIR__.'/../bootstrap/autoload.php';
TO
require __DIR__.'/../../bootstrap/autoload.php';
And
$app = require_once __DIR__.'/../bootstrap/app.php';
TO
$app = require_once __DIR__.'/../../bootstrap/app.php';
I think it helps in your requirements.
Sorry for my bad english
Upvotes: 7
Reputation: 10858
Laravel have a default .htaccess with the correct rule:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Which means if not directory (!-d) and not file (!-f), route to index.php (else hit the file/directory)
try removing the line that ends with !-d
, but i suggest you make a change to your directory name, as it will be a problem at some point for you.
Upvotes: 0