doujie4787 2014-11-13 21:52
浏览 96
已采纳

Laravel 4.2 - NotFoundHttpException

I've just started building a Laravel application and came across a problem with routing.

  1. Laravel version - 4.2
  2. PHP version - 5.5
  3. I'm using XAMPP
  4. I have the rewrite module active on Apache

Here is my Routes file:

<?php

Route::get('/', array(
    'as' => 'index',
    'uses' => 'IndexController@index'
));

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

My controllers look like this:

<?php

class IndexController extends BaseController
{
    public function index()
    {
        return View::make('index');
    }
}

<?php

class AccountController extends BaseController
{
    public function get_create()
    {
        return 'asd';
    }

    public function post_create()
    {

    }
}

Here is my error:

Symfony\Component\HttpKernel\Exception\NotFoundHttpException thrown with message ""

Stacktrace:
#11 Symfony\Component\HttpKernel\Exception\NotFoundHttpException in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:5680
#10 Illuminate\Routing\RouteCollection:match in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:5004
#9 Illuminate\Routing\Router:findRoute in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:4992
#8 Illuminate\Routing\Router:dispatchToRoute in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:4984
#7 Illuminate\Routing\Router:dispatch in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:715
#6 Illuminate\Foundation\Application:dispatch in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:696
#5 Illuminate\Foundation\Application:handle in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:7744
#4 Illuminate\Session\Middleware:handle in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:8351
#3 Illuminate\Cookie\Queue:handle in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:8298
#2 Illuminate\Cookie\Guard:handle in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:10961
#1 Stack\StackedHttpKernel:handle in C:\xampp\htdocs\Protosite\bootstrap\compiled.php:657
#0 Illuminate\Foundation\Application:run in C:\xampp\htdocs\Protosite\public\index.php:49

EDIT: One thing I forgot to mention, the index works fine, it's the account page with the error.

I've looked at similar problems but for some reason they have not solved it.

Cheers!

  • 写回答

1条回答 默认 最新

  • dongmiao260399 2014-11-14 00:45
    关注

    It sounds like your rewriting isn't working. If you add index.php to the URL right before the /account does it work?

    For example, yourdomain.com/account would become yourdomain.com/index.php/account

    If your rewriting isn't working, but you have the .htaccess file in your public directory, then you probably need to allow overrides in your apache configuration. Here is an example virtual host configuration for XAMPP and Laravel.

    I've marked the lines you need to change. Change the first and third to point to the public directory in your website's directory. Then change the second line to the domain name you're using with your website.

    <VirtualHost *:80>
        DocumentRoot "C:/xampp/htdocs/yourdomain/public"      # Change this line
        ServerName yourdomain.com                             # Change this line
        <Directory "C:/xampp/htdocs/yourdomain/public">       # Change this line
            Options Indexes FollowSymLinks ExecCGI Includes
            AllowOverride All    # This line enables .htaccess files
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>
    

    You'll need to restart Apache for these settings to take effect.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?