如何隐藏配置文件以防止直接访问?

编程入门 行业动态 更新时间:2024-10-15 06:19:31
本文介绍了如何隐藏配置文件以防止直接访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在将 Laravel 用于网络应用程序.上传生产中的所有内容,发现某些文件可以通过 url 直接访问 - 例如 example/composer.json

I am using Laravel for web app. Uploaded everything on production and found out that some of the files can be directly accessed by url - for example example/composer.json

如何避免直接访问?

推荐答案

您使用了错误的 Web 服务器配置.将您的 Web 服务器指向 public 目录并重新启动它.

You're using wrong web server configuration. Point your web server to a public directory and restart it.

对于 Apache,您可以使用以下指令:

For Apache you can use these directives:

DocumentRoot "/path_to_laravel_project/public" <Directory "/path_to_laravel_project/public">

对于 nginx,你应该改变这一行:

For nginx, you should change this line:

root /path_to_laravel_project/public;

这样做之后,所有 Laravel 文件将无法再从浏览器访问.

After doing that, all Laravel files will not be accessible from browser anymore.

更多推荐

如何隐藏配置文件以防止直接访问?

本文发布于:2023-11-01 13:26:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549446.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:配置文件   以防止

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!