错误 404,即使路由存在 - AWS,Laravel
Error 404 even though routes exist - AWS, Laravel
我刚刚在 AWS EC2 上创建了一个新实例。我有一个现有的 laravel 项目,将其推送到 github 并将其安装在我的新实例上。还安装了 composer、php、mysql、apache。当我点击 public
url 时,laravel 将我重定向到 public/auth/login
。在我的本地主机上一切都很好,但在这里它给我一个错误 404 - Not Found The requested URL /auth/login was not found on this server.
。我在 AWS 的 laravel 项目之前安装过,但从未遇到过这样的错误。可能出了什么问题?
假设您使用的是默认 Amazon Linux,您可以编辑 /etc/httpd/conf/httpd.conf
并设置 DocumentRoot "<your path to your app>/public"
,然后使用 sudo service httpd restart
重新启动 Apache。
一切都来自 .htaccess
文件。我添加了 AllowOverride All
现在一切正常!
如果您使用的是 apache 服务器,请执行以下操作
- 转到您的 apache2.conf 文件,
例如在 ubuntu 中,路径是
/etc/apache2/apache2.conf
- 通过适当的修改粘贴以下代码
<Directory /var/www/the_root_of_your_laravel_project_where_index.php_exists/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
我刚刚在 AWS EC2 上创建了一个新实例。我有一个现有的 laravel 项目,将其推送到 github 并将其安装在我的新实例上。还安装了 composer、php、mysql、apache。当我点击 public
url 时,laravel 将我重定向到 public/auth/login
。在我的本地主机上一切都很好,但在这里它给我一个错误 404 - Not Found The requested URL /auth/login was not found on this server.
。我在 AWS 的 laravel 项目之前安装过,但从未遇到过这样的错误。可能出了什么问题?
假设您使用的是默认 Amazon Linux,您可以编辑 /etc/httpd/conf/httpd.conf
并设置 DocumentRoot "<your path to your app>/public"
,然后使用 sudo service httpd restart
重新启动 Apache。
一切都来自 .htaccess
文件。我添加了 AllowOverride All
现在一切正常!
如果您使用的是 apache 服务器,请执行以下操作
- 转到您的 apache2.conf 文件,
例如在 ubuntu 中,路径是
/etc/apache2/apache2.conf
- 通过适当的修改粘贴以下代码
<Directory /var/www/the_root_of_your_laravel_project_where_index.php_exists/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>