duankanjian4642 2015-10-22 13:31
浏览 25
已采纳

安全Laravel网站托管

I developed a website using laravel and on my web hoster I have not find the public directory so , I changed the server.php
From

require_once __DIR__.'/public/index.php';

To

require_once __DIR__.'/index.php';

and I moved all the contents of the public folder in the root and the website works very well BUT the problem is when I put for example http://mywebsite.com/.env I can show the content of .env so my site is not protected.

The Question :

How can I protect my files and directories ?

Example of structure I want:

index.php
.htaccess
favicon.ico
img/
css/
js/
laravel/
      app/
      bootstrap/
      database/
      config/
      storage/
     .env
     server.php
     ...

Content of the root of my site => the public folder content

laravel directory => the other directories and files

  • 写回答

2条回答 默认 最新

  • douchilian1009 2015-10-22 15:56
    关注

    Place everything back in the public folder and revert the changes to server.php. Then in your top level directory add a .htaccess file with the code below:

    <IfModule mod_rewrite.c>
       RewriteEngine On 
       RewriteRule ^(.*)$ public/$1 [L]
    </IfModule>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 问题重发,R语言:代码运行过程中出现如下警告,请求如何解决!
  • ¥15 神经网络模型一直不能上GPU
  • ¥15 苍穹外卖拦截器token为null
  • ¥15 pyqt怎么把滑块和输入框相互绑定,求解决!
  • ¥20 wpf datagrid单元闪烁效果失灵
  • ¥15 券商软件上市公司信息获取问题
  • ¥100 ensp启动设备蓝屏,代码clock_watchdog_timeout
  • ¥15 Android studio AVD启动不了
  • ¥15 陆空双模式无人机怎么做
  • ¥15 想咨询点问题,与算法转换,负荷预测,数字孪生有关