使用Ubuntu在Nginx上托管应用程序时发生路由问题

时间:2016-03-04 15:36:33

标签: php laravel ubuntu nginx

我在Windows 8环境下安装的XAMPP上开发了Laravel 5.1应用程序。现在我想使用安装在Ubuntu 14环境中的Nginx来部署它。

我已执行https://www.digitalocean.com/community/tutorials/how-to-install-laravel-with-an-nginx-web-server-on-ubuntu-14-04中提到的所有配置。我可以访问所有网站路线,例如主页,关于,联系没有任何问题。

但访问身份验证路由时存在问题。例如当我点击登录时,而不是身份验证,它会被重新定向到分析/销售,其中包含&。34;编译.php中的InvalidArgumentException"错误说明"查看[analytics.sales.index]未找到。"

Windows 8环境和应用程序不适用于Windows 8。

我的路线档案:

<?php

/****************   Model binding into rout  ********************/

Route::model('user', 'App\User');
Route::pattern('id', '[0-9]+');
Route::pattern('slug', '[0-9a-z-_]+');

/***************    Site routes  **********************************/
Route::get('/', 'HomeController@index');
Route::get('home', array('as' => 'home' , 'uses' =>    'HomeController@index'));
Route::get('about', array('as' => 'about', 'uses' =>'PagesController@about'));
Route::get('contact', array('as' => 'contact', 'uses' =>  'PagesController@contact'));


 Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);


 /***************    Admin routes  **********************************/
 Route::group(['prefix' => 'admin', 'middleware' => 'auth'], function()   
{

  # Admin Dashboard
  Route::get('dashboard', 'Admin\DashboardController@index');


  # Users
  Route::get('user/data', 'Admin\UserController@data');
  Route::get('user/{user}/show', 'Admin\UserController@show');
  Route::get('user/{user}/edit', 'Admin\UserController@edit');
  Route::get('user/{user}/delete', 'Admin\UserController@delete');
  Route::resource('user', 'Admin\UserController');
  });

  Route::group(['prefix' => 'analytics'], function() {

  # Analytics Dashboard
  Route::get('/', 'Analytics\Dashboard\DashboardController@index');
  Route::get('dashboard/',       'Analytics\Dashboard\DashboardController@index');


  Route::get('sales',     array('uses'=>'Analytics\Sales\SalesController@index'));
  Route::post('carDetails', array('uses'=>'Analytics\Sales\SalesController@getCarDetails'));
  Route::post('modelsales', array('uses'=>'Analytics\Sales\SalesController@getModelSales'));
  Route::post('makesales', array('uses'=>'Analytics\Sales\SalesController@getMakeSales'));


 });

Auth Controller代码段:

<?php

 namespace App\Http\Controllers\Auth;

 use App\User;
 use Validator;
 use Illuminate\Http\Request;
 use App\Http\Controllers\Controller;
 use Illuminate\Foundation\Auth\ThrottlesLogins;
 use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;

 class AuthController extends Controller
 {
     use AuthenticatesAndRegistersUsers, ThrottlesLogins;

    public function __construct()
    {
       $this->middleware('guest', ['except' => 'getLogout']);
    }

    protected function validator(array $data)
    {
         return Validator::make($data, [
        'firstname' => 'required|max:255',
        'lastname' => 'required|max:255',
        'username' => 'required|max:255',
        'email' => 'required|email|max:255|unique:users',
        'designation' => 'required|max:255',
        'organisation' => 'required|max:255',
        'contact' => 'required|max:255',
        'password' => 'required|confirmed|min:6',
     ]);
   }

   protected function create(array $data)
   {

     $confirmation_code = md5(microtime() . env('APP_KEY'));
     return User::create([
        'firstname' => $data['firstname'],
        'lastname' => $data['lastname'],
        'username' => $data['username'],
        'email' => $data['email'],
        'designation' => $data['designation'],
        'organisation' => $data['organisation'],
        'contact' => $data['contact'],
        'password' => bcrypt($data['password']),
        'confirmation_code' =>$confirmation_code
    ]);
  }

 }

是否需要特定于Nginx / Ubuntu的路由配置?这个问题的根本原因是什么?

1 个答案:

答案 0 :(得分:0)

你可能在你的auth控制器的某个地方有一个重定向尝试注销/ auth / logout并重新登录并查看你是否被重定向。