冗余的 Apache RewriteRules,有没有办法缩短它们?

Redundant Apache RewriteRules, is there a way to shorten them?

我觉得我的 Rewriterule 有点多余。有没有办法将下面的 htaccess 代码缩短为一行?我想它会在某处使用 *,但我就是想不通 xD

RewriteRule ^([^/\.]+)?$ index.php?year= [L]

RewriteRule ^([^/\.]+)/?$ index.php?year= [L]

RewriteRule ^([^/\.]+)/([^/\.]+)?$ index.php?year=&month=[L]

RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?year=&month=[L]

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)?$ index.php?year=&month=&day=[L]

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?year=&month=&day=[L]

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)?$ index.php?year=&month=&day=&post=[L]

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?year=&month=&day=&post=[L]

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)?$ index.php?year=&month=&day=&post=&action= [L]

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?year=&month=&day=&post=&action= [L]

谢谢!

目前,php 脚本会检查是否设置了每个 GET 参数,并根据可用的参数执行不同的任务。我的 PHP 代码运行完美,没问题,但我只是想知道是否有办法缩短上面的 apache 规则。我也意识到这种解析 GET 参数的方式可能会产生很多漏洞,所以我很感激任何建议或反馈! :) 非常感谢^_^

您想让所有内容转到 index.php?

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /

RewriteRule . index.php [L,NC]
</IfModule>