简单的路线不工作laravel

时间:2014-05-27 05:01:03

标签: php laravel laravel-4

这里的人员是laravel routes.php

下面的代码
            Route::get('/', function()
    {
        return View::make('index');
    });

    Route::get('bid', function()
    {
      return View::make('bid');
    });

这适用于http://localhost/supadmin/public/,但不适用于http://localhost/supadmin/public/bid,可能是什么问题?我收到错误The requested URL /supadmin/public/bid was not found on this server.我还将.htaccess配置为

Options +FollowSymLinks
        RewriteEngine On

        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]

它可以像http://localhost/supadmin/public/index.php/bid一样正常工作,但我希望它可以正常工作http://localhost/supadmin/public/bid

php artisan routes显示

+--------+--------------------------+-------------+---------+----------------+---------------+
| Domain | URI                      | Name        | Action  | Before Filters | After Filters |
+--------+--------------------------+-------------+---------+----------------+---------------+
|        | GET|HEAD /               |             | Closure |                |               |
|        | GET|HEAD bid             |             | Closure |                |               |
|        | GET|HEAD bid_history     | bid_history | Closure |                |  

3 个答案:

答案 0 :(得分:1)

您需要出价/出价

Route::get('/bid', function()
    {
      return View::make('bid');
});

请确保使用 php artisan routes

注册路线

尝试通过 php artisan serve

提供服务

修改

您还应该尝试检查您的apache设置

将以下代码添加到/ etc / apache2 / sites-available / default

AllowOverride All

重启apache

答案 1 :(得分:0)

订单错了。试试这个:

Route::get('bid', function()
{
  return View::make('bid');
});

Route::get('/', function()
{
    return View::make('index');
});

答案 2 :(得分:0)

您需要启用Apache模块mod_rewrite

启用mod_rewrite:

a2enmod rewrite

然后重启Apache:

service apache2 restart