简体   繁体   中英

No Page Available - Laravel 5.2

I downloaded CMS project from github, Laravel version 5.2. I installed the composer in the folder and change the database info in .env file and the project working fine.

But only the home route is working, the rest of the routes giving me "Opps no page avaible"

The blades files are fine only the routes not working!

<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

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

Route::auth();

Route::get('/home', 'HomeController@index');

Route::get('/post/{id}', ['as' => 'home.post', 'uses' => 'AdminPostsController@post']);

Route::group(['middleware' => 'admin'], function () {

  Route::get('/admin', ['as' => 'admin.index', function () {
    return view('admin.index');
  }]);

  Route::resource('admin/users', 'AdminUsersController');

  Route::resource('admin/posts', 'AdminPostsController');

  Route::resource('admin/categories', 'AdminCategoriesController');

  Route::resource('admin/medias', 'AdminMediasController');

  Route::resource('admin/comments', 'PostCommentsController');

  Route::resource('admin/comment/replies', 'CommentRepliesController');


});

Route::group(['middleware' => 'auth'], function () {

  Route::post('comment/reply', 'CommentRepliesController@createReply');

});

and here is .htaccess file:

<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]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

Because this route is defined before your resource route, your routes will not match the resource action resulting into "Opps! no page available".

I believe moving that route definition after your resource route definitions should resolve your issue.

Give it a try & let us know if this gets resolved.

As from your described routes, Other then home routes are grouped with admin middleware .

Just confirm with your admin middleware about 404 redirection.

Hope you get some hint from there.

UPDATE
Check your admin middleware and update it with below code:

public function handle($request, Closure $next)
{
    if ((Auth::check()))
    {
        //Here, YOURADMINROLE replace with your actual admin role..
        if ((Auth::user()->hasRole('YOURADMINROLE')))
        {
            return $next($request);
        }
    }

    App::abort(403, 'Access denied');
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM