gpt4 book ai didi

php - Laravel 虚拟服务器路由不起作用

转载 作者:行者123 更新时间:2023-12-04 18:28:30 25 4
gpt4 key购买 nike

我在我的 Apache2 上安装了最新的 Laravel。我在终端运行

php artisan serve --port=8080

它有效。我有子页面和我需要的一切。但我想在不运行此命令的情况下访问。

我在 /etc/apache2/sites-available 中有下一个 mylaravel.com.conf 文件
<VirtualHost *:80>
ServerName mylaravel.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/mylaravel/public

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

我的 Laravel 文件当然在 /var/www/mylaravel .在这个配置中 mylaravel.com 有效,但是当我尝试简单的 mylaravel.com/auth/register Apache 回归

enter image description here

当我使用 php artisan [...] 这工作正常。我该如何解决?

最佳答案

不久前我遇到了同样的问题。来自 here :

If you don't have AllowOverride set to All, your Laravel .htaccess file (/public/.htaccess) won't be able to enable mod_rewrite, and your routes won't work.



尝试将以下内容添加到您的 <VirtualHost>堵塞:
<Directory "/var/www/mylaravel/public">
Options All
AllowOverride All
Allow from all
</Directory>

因此,您将拥有:
<VirtualHost *:80>
ServerName mylaravel.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/mylaravel/public

<Directory "/var/www/mylaravel/public">
Options All
AllowOverride All
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

关于php - Laravel 虚拟服务器路由不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29357306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com