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

Laravel执行make:auth命令后登录注册链接无法访问求助

Troubleshooting Laravel make:auth 404 Error on Windows

Hey there, I’ve dealt with this exact frustration before—spending hours chasing a 404 after setting up Laravel auth. Let’s walk through the most likely fixes step by step, tailored for Windows environments:

1. Verify Your Laravel Version & Auth Setup Command

First, check what Laravel version you’re running with:

php artisan --version
  • Laravel 5.x: The php artisan make:auth command works directly out of the box.
  • Laravel 6+: The make:auth command was moved to the laravel/ui package. If you skipped installing this, your auth routes/views won’t generate properly. Fix this by running:
    composer require laravel/ui
    php artisan ui bootstrap --auth # or use vue/react instead of bootstrap
    npm install && npm run dev # optional, to compile frontend assets
    

2. Check If Auth Routes Are Registered

Run this command to list all active routes:

php artisan route:list

Look for routes named login, register, password.reset, etc. If they’re missing:

  • Open routes/web.php and confirm this line exists:
    Auth::routes();
    
  • If it’s not there, add it manually, then clear the route cache:
    php artisan route:clear
    

3. Clear All Caches (Windows Loves to Hold Onto Cache!)

Windows can be stubborn with Laravel’s cached files. Run these commands in order to wipe everything clean:

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

This ensures any old cached routes or configs aren’t overriding your new auth setup.

4. Confirm Your Web Server Points to the public Folder

  • If you’re using php artisan serve, this is handled automatically.
  • If you’re using XAMPP/WAMP:
    • Set your virtual host’s document root to your Laravel project’s public folder (not the project root directory). For example: C:\laravel-project\public.
    • If you access the project via localhost/laravel-project instead of a virtual host, Laravel’s routing will break—use a virtual host or php artisan serve for development.

5. Fix Apache’s .htaccess & Rewrite Module

If you’re using Apache (XAMPP/WAMP):

  1. Make sure the public/.htaccess file exists and has the default Laravel content. If it’s missing, paste this in:
    <IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
            Options -MultiViews -Indexes
        </IfModule>
    
        RewriteEngine On
    
        # Handle Authorization Header
        RewriteCond %{HTTP:Authorization} .
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
        # Redirect Trailing Slashes If Not A Folder...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_URI} (.+)/$
        RewriteRule ^ %1 [L,R=301]
    
        # Send Requests To Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
    </IfModule>
    
  2. Enable the mod_rewrite module:
    • Open your Apache config file (httpd.conf in XAMPP/WAMP).
    • Find the line #LoadModule rewrite_module modules/mod_rewrite.so and remove the # to uncomment it.
    • Restart Apache.

6. Check Your .env File’s APP_URL

Open your .env file and ensure APP_URL matches your development URL:

APP_URL=http://127.0.0.1:8000

If you’re using a different port or domain, update this to match—incorrect APP_URL can cause routing inconsistencies.

If none of these fix the issue, try re-generating the auth scaffolding with php artisan ui:auth (for Laravel 6+) or re-running php artisan make:auth (for 5.x), and double-check that your project has proper file permissions (Windows usually handles this, but sometimes read/write access can be restricted).

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 08:41:38