404 error laravel 4 routing

2019-07-03 11:04发布

问题:

I am having troubles getting laravel to find a page when I route to it. My route is setup and being recognized as when I create link using URL::route('account-create') laravel will successfully parse that into '/account/create' as to where I want the link to go to. But upon clicking it I get a 404 error.

My route

Route::get('/account/create', array(
     'as' => 'account-create',
     'uses' => 'AccountController@getCreate'
 ));

My controller

 class AccountController extends BaseController {


    // view the create user form
    public function getCreate() 
    {
        //return View::make('account.create');
    }


}

The create.blade.php is created and put inside an account folder under app/views. commenting or uncommenting makes no difference. The 404 remains.

I have also tried:

    Route::get('/account/create', function()
{
    return 'Hello World';
});

in my routes.php still the 404 remains

Is there some configuration I am missing?

回答1:

After looking around some more I discovered I needed to enable rewrite_module on apache. Makes perfect sense really, how can laravel make clean urls if it cant rewrite the url. I knew it was going to be something simple to fix.

Thanks a lot for your replys



回答2:

Does navigating to index.php/account/create work? If so, it is probably an error in your root-level .htaccess file, or in your VirtualHost settings in httpd.conf on your server. Post the contents of .htaccess from app/public.