You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel 5.5路由Bug:登录页面跳转提示Object Not Found问题

Fixing the "Object Not Found" Login Route Error in Laravel 5.5

Alright, let's figure out why your Laravel 5.5 login route is throwing that "Object Not Found" error. I’ve seen this scenario plenty of times, so let’s walk through the most likely fixes step by step, starting with what you’ve already mentioned.

First, let’s recap your setup to align:

  • You generated the auth scaffolding with php artisan make:auth
  • Your routes file has Route::view('/', 'front.index');, Auth::routes();, and a custom GET /logout route
  • Your login button links to {{url('/login')}} but hits the error, and you’ve run php artisan route:list to debug

1. Double-check the /login route exists in route:list

You ran php artisan route:list—great first step! Make sure you see a line that looks exactly like this:

GET|HEAD | login | login | App\Http\Controllers\Auth\LoginController@showLoginForm | web,guest

If this line is missing entirely, that means Auth::routes() isn’t registering correctly. Laravel 5.5’s Auth::routes() should include the login route by default, so this would point to a conflict or missing file.

2. Check for route order conflicts

Route order matters in Laravel—specific routes need to come before wildcard/catch-all routes. Your current route order is fine, but do you have any routes like Route::get('{any}', ...) or Route::fallback(...) that appear before Auth::routes();? If so, move those to the bottom of your routes file. Wildcard routes will swallow specific paths like /login if they’re listed first.

3. Clear all cached routes and config

Laravel 5.5 can hold onto outdated cached route data, even after you’ve made changes. Run these commands in your terminal to wipe the cache:

php artisan route:clear
php artisan cache:clear
php artisan config:clear

This forces Laravel to re-register all routes from scratch, which often fixes "missing" route issues.

4. Verify your web server is pointing to the public directory

A super common cause of "Object Not Found" errors is your web server (Apache/Nginx) not using Laravel’s public folder as the document root. If your server is pointing to the main project folder instead of public, Laravel’s routing system can’t access the index.php entry point properly.

  • Apache: Update your virtual host config to set DocumentRoot to /path/to/your-project/public
  • Nginx: Ensure your config has root /path/to/your-project/public; and the try_files directive: try_files $uri $uri/ /index.php?$query_string;

You can test this quickly by running php artisan serve and visiting http://localhost:8000/login—if this works, your web server config is the problem.

5. Confirm the LoginController exists and is correctly namespaced

Double-check that App\Http\Controllers\Auth\LoginController exists in your project. The make:auth command should have generated this file, but if it’s missing, moved, or has a typo in the namespace, the route will fail. The controller should either have a showLoginForm method directly, or inherit it from the AuthenticatesUsers trait (which is the default setup).

6. Test the route directly from the command line

To rule out browser or frontend issues, test the route with curl or Artisan’s built-in server:

# Using curl
curl http://your-app-domain/login

# Or use Artisan serve
php artisan serve

If the Artisan serve test works but your web server doesn’t, circle back to step 4—your server config is definitely the issue.

Quick side note on your logout route

While unrelated to your login error, I wanted to mention: Laravel 5.5’s Auth::routes() already includes a POST /logout route. Your custom GET /logout works, but using POST is better practice to prevent accidental logouts via CSRF or prefetching. Just a heads up for later!


内容的提问来源于stack exchange,提问作者Pweb

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:37:48