如何停止Laravel目录浏览 [英] How to stop laravel directory browsing

查看:36
本文介绍了如何停止Laravel目录浏览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我转到 http://localhost:3000/SahanpCMS/resources/时,它会显示目录列表.如何停止此操作并重定向到 404 页面?

When i go to http://localhost:3000/SahanpCMS/resources/ , it shows directory listings. how can i stop this and redirect to 404 page?

推荐答案

.htaccess 文件添加到项目的根目录,然后将以下内容添加到项目中.

Add .htaccess file to the root of your project and add the following to it.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

这篇关于如何停止Laravel目录浏览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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