简体   繁体   中英

Stopping direct file access using URL

I am using laravel, In browser If I directly give the URL as below :

http://....../resources/views/users/index.blade.php

It will show the page as below :

在此处输入图片说明 .

I can't show page to public as above image.

How can I block access to particular folder or files ?

You need to edit/create .htaccess file of the directory you want to prevent the direct access from people.

As per the solutions given here :

Solutions - 1

I would just move the includes folder out of the web-root, but if you want to block direct access to the whole includes folder, you can put a .htaccess file in that folder that contains just:

 deny from all 

That way you cannot open any file from that folder, but you can include them in php without any problems.

Solution - 2

It's possible to use a Files directive and disallow access to all files, then use it again to set the files that are accessible:

 <Files ~ "^.*"> Deny from all </Files> <Files ~ "^index\\.php|css|js|.*\\.png|.*\\.jpg|.*\\.gif"> Allow from all </Files> 

Also, You can Refer to Article : How to Prevent a Directory Listing of Your Website with .htaccess

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM