在nginx的vhost站点配置文件中加入以下内容即可
if (!-d $request_filename)
{
rewrite ^/(.+)/$ /$1 permanent;
}
if ($request_uri ~* index/?$)
{
rewrite ^/(.*)/index/?$ /$1 permanent;
}
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
本文介绍了一组用于 Nginx 的 URL 重写规则。这些规则可以帮助实现更灵活的 URL 路由,包括针对不存在的目录进行重定向、移除尾部斜杠并重定向以及将所有请求重定向到 index.php 文件。这对于优化网站 URL 结构和 SEO 非常有用。
1481

被折叠的 条评论
为什么被折叠?



