laravel路线不工作

时间:2014-07-17 20:23:35

标签: php .htaccess laravel laravel-routing

我在laravel项目上的路线不起作用,基本上我正在处理一个项目,然后将其复制到另一个目录中,运行迁移和种子,然后只有根路径可以访问其他路由显示为未找到虽然它在我以前的项目上工作。这是路线文件

 <?php

Route::get('home', array(
    'as' => 'home',
    'uses' => 'DashboardController@index',
));
Route::get('acl', array(
    'as' => 'acl',
    'uses' => 'RolesAndPermssion@index',
));
    //or 
/*Route::any('admin/images/(:any)', array(
    'as' => 'admin_images',
    'uses' => 'admin.images@index',
));*/
Route::get('test',function(){
   //  System::__init();
   // return System::getAll();

   //Role::('')
  $options = array(
'validate_all' => false,
'return_type' => 'both'
);
 return "hello";

//var_dump($allValidations);


});
//use Carbon\Carbon;
Route::get('/', function()
{
  //DB::table('permission_role')->delete();
  //DB::table('permissions')->delete();
 return "hello";
//return "Product is Under Construction";
//printf("Now: %s", Carbon::now());

});

Route::get('error/permission', 'BaseController@NotPermitted');

/**
      UserController Routing Start
*/
Route::get( 'user/create',  array('as' => 'usercreate','uses' => 'UserController@create'));
Route::get( 'user/edit/{id}',array('as' => 'useredit','uses' => 'UserController@edit'));
Route::post( 'user/edit',                 'UserController@update');
Route::post('user/store','UserController@store');
Route::delete('user','UserController@delete');
Route::get('user',array('as' => 'users','uses' => 'UserController@index'));
Route::post('user',array('as' => 'users','uses' => 'UserController@index'));
Route::get( 'login',                  'UserController@login');
Route::post('login',                  'UserController@do_login');
Route::get( 'user/confirm/{code}',         'UserController@confirm');
Route::get( 'user/forgot_password',        'UserController@forgot_password');
Route::post('user/forgot_password',        'UserController@do_forgot_password');
Route::get( 'user/reset_password/{token}', 'UserController@reset_password');
Route::post('user/reset_password',         'UserController@do_reset_password');
Route::get( 'user/logout',                 'UserController@logout');
/**
      UserController Routing End
*/

/**
      RolesAndPermissionController Routing Start
*/
Route::get('roles',array('as' => 'roles','uses' => 'RolesAndPermissionController@indexRoles',));
Route::post('roles',array('as' => 'roles','uses' => 'RolesAndPermissionController@indexRoles',));
Route::get( 'roles/create',  array('as' => 'rolecreate','uses' => 'RolesAndPermissionController@createRole'));
Route::post('roles/store','RolesAndPermissionController@storeRole');
Route::get( 'roles/edit/{id}',array('as' => 'roleedit','uses' => 'RolesAndPermissionController@editRole'));
Route::post( 'roles/edit/{id}',                 'RolesAndPermissionController@updateRole');
Route::delete('roles','RolesAndPermissionController@deleteRoles');

Route::get('permissions',array('as' => 'permissions','uses' => 'RolesAndPermissionController@indexPermissions',));
Route::post('permissions',array('as' => 'permissions','uses' => 'RolesAndPermissionController@indexPermissions',));
Route::delete('permissions',array('as' => 'permissionsdelete','uses' => 'RolesAndPermissionController@deletePermissions',));
Route::get( 'permissions/create',  array('as' => 'permissioncreate','uses' => 'RolesAndPermissionController@createPermission'));
Route::post('permissions/store','RolesAndPermissionController@storePermission');
Route::get( 'permissions/edit/{id}',array('as' => 'permissionedit','uses' => 'RolesAndPermissionController@editPermission'));
Route::post( 'permission/edit/{id}',                 'RolesAndPermissionController@updatePermission');
Route::delete('permissions','RolesAndPermissionController@deletePermissions');

/**
      RolesAndPermissionController Routing Start
*/       

这是公共目录中的htaccess文件

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

和虚拟主机conf文件是这个

<VirtualHost *:80>
    ServerAdmin blahblah@gmail.com
    ServerName ngo.dev
    #ServerAlias www.example.com
    DocumentRoot /var/www/html/ngo/public/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

我可以使用indes.php / route

访问路线

1 个答案:

答案 0 :(得分:0)

我有完全相同的问题...

在我的情况下,问题是我的.htaccess文件,可能是Windows上的编辑器留下了一些奇怪的字符,所以我只是重写整个文件,现在它正在工作!