如何在流明中更改公共目录路径? [英] How to change the Public directory path in Lumen?
问题描述
默认情况下,流明与Laravel相同" 具有myApp/public
目录,用于放置所有公共文件(资产).
By default Lumen "same as Laravel" has myApp/public
directory to put all the public files (assets).
我想将该目录路径从myApp/public
更改为myApp/src/custom/public
.我该如何做到这一点?
I want to change that directory path from myApp/public
to myApp/src/custom/public
. How can I do achieve this?
推荐答案
解决了相同的问题.在此处中查找,也许会对您有所帮助. 我已经为我的Lumen应用程序完成了此解决方案,该解决方案对我有用.
Got the same problem, and solved it. Look here, maybe it will help you. I have done this solution for my Lumen application, which works for me.
更新
好吧,让我们继续进行一些更改,以使系统可以与您的树配合使用.
Ok, let's go proceeding some changes to make the system to work with your tree.
-
在应用程序的根目录中的目录
myApp\
中添加一个.htaccess
文件.写在:
Add a
.htaccess
file in the root of your application so in the directorymyApp\
. Write it in :
RewriteEngine On
RewriteCond %{THE_REQUEST} /public/([^\s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]
RewriteRule ^((?!public/).*)$ src/custom/public/$1 [L,NC]
假设您已经配置了指向\Path\myApp
的虚拟主机,我们现在就加入myApp\src\custom\public\
的索引文件.如果我们没有犯任何错误,那么我们应该进入指示错误的页面,告诉我们未找到bootstrap/app.php
文件.逻辑.
Assuming that you have configured your vhost pointing to \Path\myApp
, we now accede to the index file of myApp\src\custom\public\
. If we didn't make any mistakes, then we should get to a page that indicates an error, telling us that the bootstrap/app.php
file is not found. Logic.
-
因此,我们必须更改目录
myApp\src\custom\public
中的index.php文件:
We must therefore change the index.php file in the directory
myApp\src\custom\public
:
从此更改:
$app = require __DIR__.'/../bootstrap/app.php';
对此:
$app = require __DIR__.'/../../../bootstrap/app.php';
您现在可以直接从所需路径获得主页.
You can now get your home page directly from the path wanted.
这篇关于如何在流明中更改公共目录路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!