0
votes

Hello i am having this strange issue with laravel 5.4 is once i started i added new route admin to load dashboad view but it didn't work and instead it listed local folders inside public/admin even when i made the route return string instead of using the AdminController same result happened

Controller

    <?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class AdminController extends Controller
{
   public function dashboard()
   {
       return view('admin.dashboard');
   }
}

Routes

Route::get('/', function () {
return view('welcome');
});

/*
 * Admin Routes
 */
Route::get('admin', 'AdminController@dashboard');

URL http://website.dev/admin/

The result on web page

enter image description here

2
Show the route definitionMihai
What is route definition sorry i am still new to laravelYasser Moussa
do you put your view files in public/admin ? it should be under resources/view insteadhassan
This seems like apache's directory listing extension result. If you using apache then you must set .htaccess correctly.kodmanyagha
My views are under D:\xampp\htdocs\projects\pharmacy\resources\views\admin\daskboard.blade.php but even i am not reaching the point where i load the view @kodmanyagha yes i am actually using apache via XAMPP but how can i fix this problem thought .htaccess ?Yasser Moussa

2 Answers

0
votes

This seems like a .htaccess Problem, did you setup the .htaccess for the Root Directory?

<IfModule mod_rewrite.c>
   RewriteEngine On 
   RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

The .htaccess must be in the Root Directory of your Project.

Another simple Approach is to rename the server.php inside the Root Directory to index.php.

You may also take a look at this Stackoverflow Question.

0
votes

I am pretty sure there will be a directory named admin inside your public folder to solve this problem you have to change your directory name to another name because when you hit URL host_name/admin its goes directly inside your admin folder instead of loading your public/index.php