Laravel Filament 在本地主机上无法正常工作

问题描述 投票:0回答:1

我正在尝试访问本地主机上的 Laravel 灯丝/它不起作用。 这就是我在尝试访问 http://localhost/public/admin 时得到的结果

“路由管理/登录不支持 POST 方法。支持的方法:GET、HEAD”

当我做 php artisan 服务时,一切都工作得很好。

没有什么,因为这是全新安装。我什么都没碰过我做了 php artisan 服务,一切都工作得很好。

laravel localhost laravel-artisan laravel-filament
1个回答
0
投票

我认为你必须将 DocumentRoot 目标配置为 public/ 我一般都是通过 Dockerfile 和配置 DocumentRoot 来开发:

Apache2:

<VirtualHost *:80>
DocumentRoot /var/www/app/public

<Directory "/var/www/app/public">
    Options All
    AllowOverride All
    Require all granted
</Directory>

ErrorLog /var/log/apache2/error_log.log
CustomLog /var/log/apache2/access_log.log combined
</VirtualHost>

Nginx:

server {
listen 80;
root /var/www/app/public;

index index.php;

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location ~* \.php$ {
    fastcgi_index   index.php;
    fastcgi_pass    127.0.0.1:9000;
    include         fastcgi_params;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
}
}

另一种我经常使用但我认为不推荐的方法是在根目录中创建一个 .htaccess 文件。

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^(.*)$ public/$1 [L]

包含此内容的 .htaccess 文件将导航到您的公共目录

希望对您有帮助

© www.soinside.com 2019 - 2024. All rights reserved.