Apache

Laravel 框架自带了 public/.htaccess 文件用来从网址中删除 index.php。如果你用的是 Apache 来运行你的 Laravel 应用,请务必启用 Apache 的 mod_rewrite 模块。

如果 Laravel 自带的 .htaccess 文件在你的 Apache 中不起作用,请试一试下面的配置:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Nginx

在 Nginx 中,将下面的指令放到站点配置文件中就可以实现美化链接的功能:

location / {
try_files $uri $uri/ /index.php?$query_string;
}
Last modification:February 20th, 2022 at 12:15 am