4

I migrate a web page made in Laravel to a server witch Cpanel, all the routes are working find except the Auths like /login. When you try to enter there route it appear a 404 error. Here is the page: http://elgloborojocatalogos.com.mx/

And my routes are :

<?php

Auth::routes();

// Routes or function calls for this project.
Route::get('/', 'GlobosController@catalogo');

Route::get('globos',['uses' =>'GlobosController@index']);

Route::post('globos/store',['uses' =>'GlobosController@store'])->middleware('auth');

Route::get('globos/retrieveall',['uses' => 'GlobosController@retrieveAll'])->middleware('auth');

Route::get('globos/retrieve/{no_pages}',['uses'=> 'GlobosController@retrieve'])->middleware('auth');

Route::get('globos/pages',['uses'=>'GlobosController@pages'])->middleware('auth');

Route::get('globos/pagesp/{type}', ['uses' =>'GlobosController@pagesp'])->middleware('auth');   

Route::get('/home', function(){ return redirect('globos/pages');});

Route::delete('globos/deleteGlobo/{id}', ['uses' =>'GlobosController@deleteGlobo'])->middleware('auth');

Route::post('globos/findGlobo',['uses'=>'GlobosController@findGlobo'])->middleware('auth');

Route::get('globos/imprimirCatalogo',['uses'=>'GlobosController@imprimirCatalogo'])->middleware('auth');

//Users
// Authentication Routes...
Route::get('login', 'Auth\LoginController@showLoginForm');
Route::post('login', 'Auth\LoginController@login');
Route::post('logout', 'Auth\LoginController@logout');
  • What version of PHP is running on the server? – Jeremy Harris Dec 21 '16 at 17:02
  • 1
    The helper function Auth::routes() will register for you the Route::get('login'), Route::post('login'), Route::post('logout') and some other (registration, password forgot). You do not ave to add them manually. The best thing is to do an `php artisan route:list` and see the output on that one. – Alex Dec 21 '16 at 17:06
  • In the server we are using php 5.6.4 @JeremyHarris – Ana María González Dec 21 '16 at 17:08

3 Answers3

17

You are trying to access http://elgloborojocatalogos.com.mx/login , But it shows file not found. which is pretty obvious, because you are missing index.php before login like below

http://elgloborojocatalogos.com.mx/index.php/login

Now it will do the trick, but sure it looks ugly. So for removing index.php you need to add a .htaccess file in the public_html folder, which is root. So, simply create a file and name it .htaccess and copy paste this following line of code to the file.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase //
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?$1 [L]
</IfModule>

It should work as expected now

Afikur Rahman
  • 347
  • 2
  • 13
  • 1
    This doesn't work with Laravel signed URL. Please improve this answer. Correct version is this one : https://stackoverflow.com/a/46647507/1093811 – Dhrumil Bhankhar Aug 23 '20 at 12:13
0

Most of your routes are giving us a 404, example:

enter image description here

Event /globos which has no middlewares. So I'll have to assume we are not looking to the same app you have in your development environment. Have you uploaded it correctly?

If it was only an auth problem a page like /globos/pages should redirect us to auth, but that doesn't happen, so it's a general routes problem.

Also Auth::routes(); should give you login, logout and register, so you don't need to create any other login routes, or, you may just delete that Auth::routes(); line.

Antonio Carlos Ribeiro
  • 86,191
  • 22
  • 213
  • 204
0

Please change .htaccess as mentioned by answer here : https://stackoverflow.com/a/46647507/1093811

Below works with Laravel signed URLs as well.

<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>
Dhrumil Bhankhar
  • 1,301
  • 1
  • 14
  • 15