如标题所述,我在 Laravel 项目中遇到错误 403(页面标题)。在本地,它可以正常工作,但是当我试图将它放在网络主机/我的域上时,它会给我:
Forbidden
You don't have permission to access / on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
我从公用文件夹中删除了 .htaccess
文件,但没有任何反应。
有什么解决办法吗?
最佳答案
您的 .htaccess
没有被 apache 解析,因为在虚拟主机配置中缺少 AllowOverride All
指令。 .htaccess
文件是 Laravel 所必需的。把它放回去。然后更改服务器上的 apache 虚拟主机配置以允许 .htaccess
。
<VirtualHost *:80>
ServerName www.example.net
DocumentRoot "/var/www/html/example3"
<Directory /var/www/html/example3>
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
像这样更改您的虚拟主机并通过 sudo service apache2 restart
重新启动 apache。
将 www.example.net
和 /var/www/html/example3
替换为正确的详细信息。
关于php - Laravel 403 禁止错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43010415/