[英]How to set the base path in Laravel 5
我將Laravel的公用文件夾移到了根文件夾 ,並將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 /公
但是我需要的是:
/ htdocs中/公
我已經檢查了/config/
配置文件,但是沒有任何內容。
請告訴我如何解決。 謝謝
(我的laravel版本是5.0.33 )
PS:我嘗試過這種方法: 共享主機上的Laravel 5-錯誤的public_path()
我在AppServiceProvider
覆蓋了public_path()
$this->app->bind('path.public', function() {
return base_path() . '/';
});
但是什么都沒有改變。
您可以通過將公用文件夾添加到通常在/ public文件夾中找到的index.php文件中來正確綁定公用文件夾
// set the public path to this directory
$app->bind('path.public', function() {
return __DIR__;
});
您可能要在此之后清除緩存,因為路徑可能之前已經緩存過。 如果您沒有ssh訪問
bootstrap/cache/config.php
的服務器,則可以手動找到和刪除緩存的配置。
與其移動公用文件夾,不如嘗試在根目錄中添加具有以下內容的.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
這會將所有請求重定向到/ public
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.