如何在流明中更改公共目录路径? [英] How to change the Public directory path in Lumen?

查看:72
本文介绍了如何在流明中更改公共目录路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,流明与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.

  1. 在应用程序的根目录中的目录myApp\中添加一个.htaccess文件.写在:

  1. Add a .htaccess file in the root of your application so in the directory myApp\. 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.

  1. 因此,我们必须更改目录myApp\src\custom\public中的index.php文件:

  1. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆