laravel Apache 错误:没有匹配的 DirectoryIndex
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37012303/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Apache Error: No matching DirectoryIndex
提问by Nas Atchia
It's the first time I'm trying to deploy my LaravelApp on my shared hosting account.
这是我第一次尝试在我的共享主机帐户上部署我的Laravel应用程序。
The folder structure is as follows:
文件夹结构如下:
|--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
When I go to my subdomain url, I get this:
当我转到我的子域网址时,我得到以下信息:
I've checked my error.log file and I get the following 403 forbidden error:
我检查了我的 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
Hope anyone can help me. Thanks!
希望任何人都可以帮助我。谢谢!
回答by Hongbin Wang
You can try to add .htaccess
in the laraval
directory and laravel/public
directory.
您可以尝试.htaccess
在laraval
目录和laravel/public
目录中添加。
<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>
Maybe you also need to point Laravel to a public directory to make it work. For example, if you've installed Laravel in /path_to_laravel/public/
directory, you need to use these settings in your Apache config:
也许您还需要将 Laravel 指向公共目录才能使其工作。例如,如果你已经在/path_to_laravel/public/
目录中安装了 Laravel ,你需要在你的 Apache 配置中使用这些设置:
DocumentRoot "/path_to_laravel/public/"
<Directory "/path_to_laravel/public/">
After that restart Apache and your app should work as expected.
之后重新启动 Apache,您的应用程序应该可以按预期工作。
回答by Behnam Azimi
Maybe it's late to answering but,
Make sure that you have the right permission on your public/index.php
file.
For example, if your user is core, you should set it as the owner of index.php
too.
也许回答晚了,但请确保您对public/index.php
文件拥有正确的权限。例如,如果您的用户是core,您也应该将其设置为所有者index.php
。
To change it you can use this command:
要更改它,您可以使用以下命令:
sudo chown -R core public/index.php
sudo chown -R core public/index.php