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 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。
  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题