Thursday, April 13, 2017

Why after migrate a Laravel application on my remote server this route doesn't work?

this is the first time that I try to migrate a Laravel application from my local environment to my remote server.

So basically I have uploaded the entire content of my local Laravel 5.4 application into this folder of my remote server:

/var/www/html/HotelRegistration

Then I am trying to opening this URL into the browser (my remote server):

http://89.36.211.48/HotelRegistration/public/

and how you can see the standard Laravel homepage appear (it is expected, I yet have to replace this page with a custom one).

The problem is that in my web.xml file I have declared these routes:

Route::get('/', function () {
    return view('welcome');
});

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

Route::post('contact', 'EnquiryController@index');


Route::resource('/registration', 'RegistrationController');

The first one is the one related to the standard Laravel page that works fine, the last one is:

Route::resource('/registration', 'RegistrationController');

and it should handle HTTP GET request toward the /registration by the RegistrationController class, this controller class contains this index() method:

/**
 * Metodo che mostra la pagina di registrazione di un nuovo utente albergatore.
 * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
 */
public function index(){
    Log::info('index() START');

    return view('/registration/index');

}

that opening this URL:

http://89.36.211.48/HotelRegistration/public/registration

should show a registration page. But, as you can see opening it I obtain a Not Found error message.

Into the /var/www/html/HotelRegistration/storage/logs/laravel.log file there is nothing, I expected the output of the log putted at the beginning of the previous method controller, so it seems that it doesn't not enter in this method.

The strange thing is that opening the same URL on my localhost system (http://localhost/HotelRegistration/public/registration) it works fine.

I am thinking that maybe it could be a routes problem (maybe some route is missing), if I perform this statment on my local environment:

php artisan route:list

I obtain:

+--------+-----------+----------------------------------+----------------------+------------------------------------------------------+--------------+
| Domain | Method    | URI                              | Name                 | Action                                               | Middleware   |
+--------+-----------+----------------------------------+----------------------+------------------------------------------------------+--------------+
|        | GET|HEAD  | /                                |                      | Closure                                              | web          |
|        | GET|HEAD  | activate                         |                      | App\Http\Controllers\RegistrationController@activate | web          |
|        | GET|HEAD  | api/user                         |                      | Closure                                              | api,auth:api |
|        | GET|HEAD  | contact                          |                      | Closure                                              | web          |
|        | POST      | contact                          |                      | App\Http\Controllers\EnquiryController@index         | web          |
|        | GET|HEAD  | errors                           | errors               | Closure                                              | web          |
|        | POST      | registration                     | registration.store   | App\Http\Controllers\RegistrationController@store    | web          |
|        | GET|HEAD  | registration                     | registration.index   | App\Http\Controllers\RegistrationController@index    | web          |
|        | GET|HEAD  | registration/create              | registration.create  | App\Http\Controllers\RegistrationController@create   | web          |
|        | DELETE    | registration/{registration}      | registration.destroy | App\Http\Controllers\RegistrationController@destroy  | web          |
|        | PUT|PATCH | registration/{registration}      | registration.update  | App\Http\Controllers\RegistrationController@update   | web          |
|        | GET|HEAD  | registration/{registration}      | registration.show    | App\Http\Controllers\RegistrationController@show     | web          |
|        | GET|HEAD  | registration/{registration}/edit | registration.edit    | App\Http\Controllers\RegistrationController@edit     | web          |
+--------+-----------+----------------------------------+----------------------+------------------------------------------------------+--------------+

that contains this route:

|        | GET|HEAD  | registration                     | registration.index   | App\Http\Controllers\RegistrationController@index    | web          |

that should be the route related to the previous index() method of my controller.

But I can found it also performing the same statment on my remote environment:

root@Betrivius-VPS:/var/www/html/HotelRegistration# php artisan route:list
+--------+-----------+----------------------------------+----------------------+------------------------------------------------------+--------------+
| Domain | Method    | URI                              | Name                 | Action                                               | Middleware   |
+--------+-----------+----------------------------------+----------------------+------------------------------------------------------+--------------+
|        | GET|HEAD  | /                                |                      | Closure                                              | web          |
|        | GET|HEAD  | activate                         |                      | App\Http\Controllers\RegistrationController@activate | web          |
|        | GET|HEAD  | api/user                         |                      | Closure                                              | api,auth:api |
|        | GET|HEAD  | contact                          |                      | Closure                                              | web          |
|        | POST      | contact                          |                      | App\Http\Controllers\EnquiryController@index         | web          |
|        | GET|HEAD  | errors                           | errors               | Closure                                              | web          |
|        | GET|HEAD  | registration                     | registration.index   | App\Http\Controllers\RegistrationController@index    | web          |
|        | POST      | registration                     | registration.store   | App\Http\Controllers\RegistrationController@store    | web          |
|        | GET|HEAD  | registration/create              | registration.create  | App\Http\Controllers\RegistrationController@create   | web          |
|        | GET|HEAD  | registration/{registration}      | registration.show    | App\Http\Controllers\RegistrationController@show     | web          |
|        | PUT|PATCH | registration/{registration}      | registration.update  | App\Http\Controllers\RegistrationController@update   | web          |
|        | DELETE    | registration/{registration}      | registration.destroy | App\Http\Controllers\RegistrationController@destroy  | web          |
|        | GET|HEAD  | registration/{registration}/edit | registration.edit    | App\Http\Controllers\RegistrationController@edit     | web          |
+--------+-----------+----------------------------------+----------------------+------------------------------------------------------+--------------+

So what could be the problem? Why on my remote environment this URL (http://89.36.211.48/HotelRegistration/public/registration) seems not to be hanbdled as done in the local one?

What could be the problem? What am I missing? How can I try to fix it?



via AndreaNobili

Advertisement