[英]Deny Access to all directory and file listing with .htaccess
What is the code used in .htaccess
to prevent access of other files in my public folder ( LARAVEL project under shared hosting )? .htaccess
用于阻止访问公用文件夹(共享托管下的LARAVEL项目)中其他文件的代码是什么?
I have a file called index.php
and I want this file to be the only file able to access all the other files/directories. 我有一个名为
index.php
的文件,并且我希望该文件是唯一能够访问所有其他文件/目录的文件。
I have seen other solutions here on StackOverFlow but they do not match above requirement. 我在StackOverFlow上看到了其他解决方案,但它们不符合上述要求。
You can block an access to a folder with this code in the .htaccess
您可以使用
.htaccess
此代码阻止对文件夹的访问
<Directory "/file/">
deny from all
</Directory>
You have to modify the "file" by the name of your files. 您必须通过文件名来修改“文件”。
But I do not know if that's what you're looking for so you can do this too: 但是我不知道这是否是您要寻找的,因此您也可以这样做:
RewriteEngine on
RewriteRule ^(.+)$ index.php
Laravel has it's own .htaccess ready and that should work with your shared hosting too.. Laravel已经准备好了自己的.htaccess,并且也可以与您的共享主机一起使用。
myfoldersite/public/.htaccess
move to 搬去
myfoldersite/.htaccess
and rename 然后重命名
myfoldersite/server.php
to 至
index.php
And try browsing your site again, let's see if that works. 然后尝试再次浏览您的网站,让我们看看是否可行。
Cheers! 干杯!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.