【问题标题】:Apache Error: No matching DirectoryIndexApache 错误:没有匹配的 DirectoryIndex
【发布时间】:2016-05-03 18:58:40
【问题描述】:

这是我第一次尝试在我的共享主机帐户上部署我的 Laravel 应用程序。

文件夹结构如下:

|--laravel
  |--app
     |--GoPublic.php // use to point to new location 
  |--bootstrap
  |--config
  |--database
  // more folders 
|--public_html
  |--app // my subdomain document root
     |--assets
     |--index.php // GoPublic.php point to this file

当我转到我的子域网址时,我得到了这个:

我检查了我的 error.log 文件并收到以下 403 禁止错误:

[autoindex:error] [pid 910782] [] AH01276: Cannot serve directory /home/user/public_html/app/: No matching DirectoryIndex (index.php,Index.html,Index.htm,index.html.var,index.htm,index.html,index.shtml,index.xhtml,index.wml,index.perl,index.pl,index.plx,index.ppl,index.cgi,index.jsp,index.js,index.jp,index.php4,index.php3,index.phtml,default.htm,default.html,home.htm,index.php5,Default.html,Default.htm,home.html) found, and server-generated directory index forbidden by Options directive

希望任何人都可以帮助我。谢谢!

【问题讨论】:

  • 你已经拆散了 Laravel 目录结构。 /public/index.php 是网络服务器的入口点。就你所拥有的而言,它是如此特定于你的环境,没有人可以说可以提供帮助。
  • 我应该怎么做才能解决这个问题?
  • 您希望保持 Laravel 的结构不变,并将您的子域指向 /laravel/public/。
  • 当我指向 /laravel/public/ 时出现同样的错误

标签: php apache laravel


【解决方案1】:

也许现在回答已经晚了,但是, 确保您对 public/index.php 文件具有正确的权限。 例如,如果您的用户是核心,您也应该将其设置为index.php 的所有者。

要更改它,您可以使用以下命令:

sudo chown -R core public/index.php

【讨论】:

    【解决方案2】:

    您可以尝试在laraval目录和laravel/public目录中添加.htaccess

    <IfModule mod_rewrite.c>
    WriteEngine On
    RewriteBase /laravel/public/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    

    也许您还需要将 Laravel 指向一个公共目录才能使其工作。例如,如果您已将 Laravel 安装在 /path_to_laravel/public/ 目录中,则需要在 Apache 配置中使用这些设置:

    DocumentRoot "/path_to_laravel/public/"
    <Directory "/path_to_laravel/public/">
    

    重启 Apache 后,您的应用应该可以正常运行了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-20
      • 1970-01-01
      • 2017-07-08
      • 2019-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多