php laravel nginx routes digital-ocean

php - mamp laravel nginx



Rutas de Laravel no encontradas en nginx (3)

cuando intento acceder a mi aplicación de prueba, solo funciona la ruta de índice: malte.italoborg.es

Si intento acceder a otra ruta, como: malte.italoborg.es/admin

Recibí el error 404.

Mi archivo de aplicación nginx:

server { listen 80; server_name malte.italoborg.es; root /home/italo/www/malte.italoborg.es/public; charset utf-8; location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } access_log off; error_log /home/log/nginx/malte.italoborg.es-error.log error; error_page 404 /index.php; sendfile off; # Point index to the Laravel front controller. index index.php; location / { try_files $uri $uri/ /index.php; } location ~ /.php$ { try_files $uri /index.php =404; fastcgi_split_path_info ^(.+/.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ //.ht { #deny all; } }

Intenté esta solución en otro enlace en StackOverflow, pero no funcionó para mí.

Todas las rutas de Laravel "no encontradas" en nginx

Estoy usando nginx en Digital Ocean.

::ACTUALIZAR::

Mi routes.php

<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It''s a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get(''/'', [''as'' => ''site.welcome.index'', ''uses'' => ''Site/WelcomeController@index''] ); Route::group([''prefix'' => ''admin''], function () { // Login Route::get(''login'', [''as'' => ''admin.auth.login'', ''uses'' => ''Admin/Auth/AuthController@getLogin''] ); Route::post(''login'', [''as'' => ''admin.auth.login'', ''uses'' => ''Admin/Auth/AuthController@postLogin''] ); Route::get(''logout'', [''as'' => ''admin.auth.logout'', ''uses'' => ''Admin/Auth/AuthController@getLogout''] ); // Password Route::get(''password/email'', [''as'' => ''admin.password.email'', ''uses'' => ''Admin/Auth/PasswordController@getEmail''] ); Route::post(''password/email'', [''as'' => ''admin.password.email'', ''uses'' => ''Admin/Auth/PasswordController@postEmail''] ); // Password reset Route::get(''password/reset/{token}'', [''as'' => ''admin.password.reset'', ''uses'' => ''Admin/Auth/PasswordController@getReset''] ); Route::post(''password/reset'', [''as'' => ''admin.password.reset'', ''uses'' => ''Admin/Auth/PasswordController@postReset''] ); Route::group([''middleware'' => ''auth''], function () { // Home Route::get(''/'', [''as'' => ''admin.home.index'', ''uses'' => ''Admin/HomeController@index'']); // My Account Route::get(''profile'', [''as'' => ''admin.profile.edit'', ''uses'' => ''Admin/ProfileController@edit''] ); Route::put(''profile'', [''as'' => ''admin.profile.update'', ''uses'' => ''Admin/ProfileController@update''] ); // Nail polish Route::resource(''polishes'', ''Admin/NailPolishController''); // Brands Route::resource(''brands'', ''Admin/BrandController''); // Types Route::resource(''types'', ''Admin/TypeController''); }); });


Intenta cambiar esto

location / { try_files $uri $uri/ /index.php; }

a esto

location / { try_files $uri $uri/ /index.php?$query_string; }

Y también eliminar esta línea:

try_files $uri /index.php =404;


Solución para Laravel 5.1:
$ vi /etc/nginx/sites-available/default

Comentar:
# try_files $uri $uri/ =404;

Añadir:
try_files $uri $uri/ /index.php;


Para el lumen y el laberinto esto resolvió mi problema:

Cambié la raíz del documento en nginx a la raíz de mi proyecto:

root /usr/you/laravelinstall/public;