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

Laravel 5部署至虚拟主机遇路径问题求助

Troubleshooting Your Laravel 5 Deployment Issue

Hey there, let's walk through the likely issues causing your Laravel 5 app to still reference your local XAMPP path (C:\xampp\htdocs) after deploying to your virtual host. Here are the key fixes to check:

1. Fix the APP_URL (not APP_PATH) in your .env file

First, it looks like you might have a typo—Laravel uses APP_URL, not APP_PATH, to define the application's base URL. Update this to match your live subdirectory:

APP_URL=https://domain.com/adminpanel

If you leave this set to http://localhost, Laravel will keep trying to use your local development path for assets, routes, and internal references.

2. Update the index.php file to point to your Laravel core files

Since you placed the Laravel core in a laravel folder outside public_html, and your public folder is at domain.com/adminpanel, you need to adjust the paths in public/index.php to correctly locate the core files.

Open public/index.php and modify these two lines:

// From this:
require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';

// To this (adjust the path based on your folder structure):
require __DIR__.'/../../laravel/vendor/autoload.php';
$app = require_once __DIR__.'/../../laravel/bootstrap/app.php';

This tells the app where to find the Laravel framework files instead of looking for them in your local ../ directory.

3. Adjust the .htaccess for your subdirectory

The default Laravel .htaccess in the public folder assumes it's the root directory. Since you're using /adminpanel, add a RewriteBase line to the top of the .htaccess file:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /adminpanel/  # Add this line
    RewriteRule ^(.*)$ public/$1 [L]
    # ... rest of the default rules
</IfModule>

This ensures the server correctly routes requests to the index.php file in your subdirectory.

4. Clear cached configurations on the server

Even though you cleared caches locally, the cached config files might still reference your local path. Connect to your virtual host via SSH and run these commands:

php artisan route:clear
php artisan view:clear
php artisan cache:clear
php artisan config:clear  # This is crucial for updating .env changes
composer dump-autoload

This will wipe any residual cached data that's pointing to your XAMPP directory.

5. Verify file permissions

Make sure the storage and bootstrap/cache directories in your Laravel core folder have the correct write permissions. On most hosts, you can run:

chmod -R 755 storage bootstrap/cache

If permissions are too restrictive, Laravel might not be able to generate new cache files, forcing it to fall back to old local references.

6. Confirm your virtual host's document root

Double-check that your hosting provider has set the document root for domain.com/adminpanel to point directly to your public folder. If the document root is still set to public_html, the server won't route requests correctly to your Laravel app.


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 06:34:31