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

修改XAMPP端口至8000后Laravel虚拟主机路由访问错误求助

Fixing Laravel Route Access After Changing XAMPP Port to 8000

Hey there, let's get this sorted out for you! The main issue here is how you're formatting your URLs—you've got the port number in the wrong spot.

What's Wrong with Your Current URLs?

When you try to visit http://laravel.test/about:8000/ or http://laravel.test/homepage:8000/, your browser interprets about:8000 and homepage:8000 as part of the path, not the port number. That's why you're hitting errors.

Correct URL Format

Port numbers always go right after the domain name, separated by a colon, before the route path. So your valid URLs should be:

  • http://laravel.test:8000/about
  • http://laravel.test:8000/homepage

Double-Check These Configs to Avoid Other Issues

If you still run into problems after fixing the URL format, verify these settings:

  • Apache Port Configuration:
    Open XAMPP's Apache httpd.conf file and make sure the Listen directive is set to 8000:

    Listen 8000
    

    Then check your httpd-vhosts.conf file (usually in xampp/apache/conf/extra/) to ensure your virtual host uses port 8000:

    <VirtualHost *:8000>
        DocumentRoot "C:/xampp/htdocs/your-laravel-project/public"
        ServerName laravel.test
        ErrorLog "logs/laravel.test-error.log"
        CustomLog "logs/laravel.test-access.log" common
    </VirtualHost>
    
  • Hosts File Setup:
    Make sure your local hosts file maps laravel.test to 127.0.0.1:

    • On Windows: Edit C:\Windows\System32\drivers\etc\hosts and add 127.0.0.1 laravel.test
    • On Mac/Linux: Edit /etc/hosts and add 127.0.0.1 laravel.test
  • Laravel Route Configuration:
    Confirm your routes in routes/web.php are correctly defined (no typos!). For example:

    Route::get('/about', function () {
        return view('about');
    });
    
    Route::get('/homepage', function () {
        return view('homepage');
    });
    
  • Restart Apache:
    After making any configuration changes, restart the Apache service in XAMPP to apply the updates.

Once you've fixed the URL format and verified these settings, your routes should load without errors!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 09:47:09