How to hide config files from direct access?

后端 未结 9 2076
野性不改
野性不改 2020-11-22 14:46

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 http://example.com/compo

9条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 15:15

    Point your web server to a public directory and restart it.

    For Apache you can use these directives:

    DocumentRoot "/path_to_laravel_project/public"
    
    

    Also You Can Deny files in .htaccess too.

    
    Order Allow,Deny
    Deny from all
    
    

    for multiple files you can add above files tag multiple times in .htaccess files.

提交回复
热议问题