gpt4 book ai didi

php - 如何在 Laravel 5 中设置基本路径

转载 作者:行者123 更新时间:2023-12-02 04:19:00 24 4
gpt4 key购买 nike

我将 Laravel 的公共(public)文件夹移动到根文件夹,并将 Laravel 移动到它自己的文件夹。所以我可以在共享主机上使用 Laravel。它看起来像这样:

2015/08/04  18:13    <DIR>          .
2015/08/04 18:13 <DIR> ..
2015/08/01 17:50 896 .htaccess
2015/07/29 17:39 0 favicon.ico
2015/07/29 17:39 1,844 index.php
2015/08/04 17:19 <DIR> laravel
2015/08/04 17:20 <DIR> public
2015/08/01 17:46 1,165 README.md
2015/08/01 16:18 34 robots.txt
2015/08/04 17:20 <DIR> static

例如,我使用 public_path() 并得到以下结果:

/htdocs/laravel/public

但我需要的是这个:

/htdocs/public

我检查了 /config/ 中的配置文件,但没有任何内容。

请告诉我如何修复它。谢谢

(我的laravel版本是5.0.33)


PS:我尝试过这个方法: Laravel 5 on shared hosting - wrong public_path()

我覆盖了AppServiceProvider中的public_path()

$this->app->bind('path.public', function() {
return base_path() . '/';
});

但是什么都没有改变。

最佳答案

您可以通过将其添加到通常位于/public 文件夹中的 index.php 文件来正确绑定(bind)公共(public)文件夹

// set the public path to this directory
$app->bind('path.public', function() {
return __DIR__;
});

You may want to clear your cache after this as the paths may have been cached before. The cached config can be located and deleted manually if you don't have ssh access to the server at bootstrap/cache/config.php

关于php - 如何在 Laravel 5 中设置基本路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31805814/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com