在VPS中开发Laravel后,只加载主页



我终于在vps上加载了我的laravel项目,一切都很顺利,直到我注意到除了主页,所有其他页面都返回了404错误。我做了所有这些说明,但它没有修复它。

php artisan view:cache
php artisan route:cache
php artisan config:cache
php artisan key: generate

但其他页面根本没有加载。重写模块也是活动的

首先,启用重写模式

sudo a2enmod rewrite
sudo service apache2 restart

然后

nano /etc/apache2/apache2.conf

后的更改

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

进入

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

然后再次重新启动apache

sudo service apache2 restart

如果不起作用,请按照上述步骤更改your-domain.conf文件

该文件将位于

/etc/apache2/sites-available/your-domain.conf

正如我在你的评论中看到的,上面的文件将包含一个类似的代码块

<Directory /var/www/html/myproject/public>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

将其更改为

<Directory /var/www/html/myproject/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

最后

sudo service apache2 restart

最新更新