laravel的public相关问题

之前装过一次laravel,直接访问laravel下的public就可以打开欢迎页面了.
这次从别人那里拷贝过来一个,访问public后直接就显示public下面的文件了,如下图,这是怎么回事啊?(新人,麻烦说的详细些,非常感谢)
图片描述

阅读 3.4k
4 个回答

nginx的配置问题,你这种情况应该是看一下你的nginx的server模块 index 有没有index.php , 然后再看下nginx有没有配置处理PHP文件的php-fpm

详细参考:


Pretty URLs

Apache

The framework ships with a public/.htaccess file that is used to allow URLs without index.php. If you use Apache to serve your Laravel application, be sure to enable the mod_rewrite module.

If the .htaccess file that ships with Laravel does not work with your Apache installation, try this one:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

https://laravel.com/docs/5.1

首先你看看你是否是通过HTTP协议进行访问的,出现这种情况一般都是通过file:\协议进行访问出现的现象。

谢谢各位回答,的确是服务器这边的问题,Gundy的答案是Nginx的处理方法.我的是apache服务器,下面这段是百度的结果
Apache目录下,有一个conf目录,打开里面的"httpd.conf"文件,找到 DirectoryIndex 这段.把它改成DirectoryIndex index.php index.Html index.html 这样,你的网站目录的默认首页是 index.php, 如果没有index.php系统会自动寻找index.html、html做为默认首页了。
图片描述

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题