[英]Laravel project, how to make public folder not accessable by root
I have my Laravel project that is hosted on a server, I made a copy of that project for testing and development on my local pc, but there is a difference that I don't know how to solve.我有一个托管在服务器上的 Laravel 项目,我制作了该项目的副本以在我的本地 PC 上进行测试和开发,但存在一个我不知道如何解决的差异。 On my local pc I do not need to specify public folder to access css files and other stuff, but on my server I have to specify, otherwise I doesn't find those files in public folder.
在我的本地电脑上,我不需要指定公用文件夹来访问 css 文件和其他东西,但在我的服务器上我必须指定,否则我在公用文件夹中找不到这些文件。 Example code on server:
服务器上的示例代码:
<link rel="stylesheet" href="/public/css/main.css">
And on my local pc在我的本地电脑上
<link rel="stylesheet" href="/css/main.css">
So I would love to make this thing the same on my local project, because now everytime I push changes to the server I need to add public to all the stuff and that's annoying.所以我很想在我的本地项目上做同样的事情,因为现在每次我将更改推送到服务器时,我都需要向所有内容添加公共内容,这很烦人。 If I understand correctly it is done for security purposes, but I don't know how to make it on my project.
如果我理解正确,这是出于安全目的,但我不知道如何在我的项目中使用它。
使用 Laravel 的asset() 函数,如下所示,
<link rel="stylesheet" href="{{asset('css/main.css')}}">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.