简体   繁体   English

"Laravel项目,如何使root无法访问公共文件夹"

[英]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.

相关问题 如何在 Laravel 中以 root 身份创建公共文件夹? - How to make public folder as root in Laravel? 如何从根文件夹重定向到Laravel中的公用文件夹 - How to redirect from root folder to public folder in laravel 如何在Laravel中使变量可访问整个控制器 - How to make a variable accessable to the whole controller in laravel Laravel 5:如何避免公共文件夹,尝试从本地主机中的 root 打开 - Laravel 5: How to avoid public folder, trying to open from root in localhost 如何在没有公用文件夹的根目录下运行 laravel? - How to run laravel in root directory without the public folder? Laravel,不会将文件上传到 Public_html,而是在 laravel 根项目中创建文件夹 - Laravel, Wont upload file to Public_html but instead creating folder in laravel root project laravel framework:将index.php从公用文件夹移动到项目根目录是否安全? - laravel framework : is it safe to move index.php from public folder to the project root? Laravel 访问其他 Laravel 项目的公用文件夹 - Laravel Access the public folder of other Laravel Project 如何从公共文件夹在php laravel中制作轮播图像幻灯片 - How to make carousel image slide in php laravel from public folder 如何将laravel项目指向共享主机中public_html下的公共文件夹 - How to point laravel project to a public folder under public_html in shared hosting
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM