Laravel执行make:auth命令后登录注册链接无法访问求助
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:authcommand works directly out of the box. - Laravel 6+: The
make:authcommand was moved to thelaravel/uipackage. 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.phpand 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
publicfolder (not the project root directory). For example:C:\laravel-project\public. - If you access the project via
localhost/laravel-projectinstead of a virtual host, Laravel’s routing will break—use a virtual host orphp artisan servefor development.
- Set your virtual host’s document root to your Laravel project’s
5. Fix Apache’s .htaccess & Rewrite Module
If you’re using Apache (XAMPP/WAMP):
- Make sure the
public/.htaccessfile 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> - Enable the
mod_rewritemodule:- Open your Apache config file (
httpd.confin XAMPP/WAMP). - Find the line
#LoadModule rewrite_module modules/mod_rewrite.soand remove the#to uncomment it. - Restart Apache.
- Open your Apache config file (
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

