Laravel .htaccess 文件的内容应该是这样的:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
您的 webroot 必须设置为 /public 目录。不要尝试搜索将 index.php 和 .htaccess 文件从 /public 移动到 Laravel 应用程序根目录的其他解决方案。绝对没有理由将 webroot 从 /public 移动到 /。index.php 位于 /public 是有原因的。如果您的虚拟主机不提供将 Web 根目录移动到另一个目录的功能,请切换您的主机。