重写不存在的文件夹以在不重定向的情况下进行查询

Rewrite non-existing folder to be query without redirect

我需要一种方法将 example.com/159985870458322944/ 或任何其他随机 18 位字符串重写为 example.com/?159985870458322944,其中该字符串是查询键。它也不需要改变URL,所以URL保持example.com/159985870458322944,但显示主目录(example.com/)中的index.php通过的内容查询。


我目前有这个(不工作)

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^/([0-9]+)$ /? [NC,P]
</IfModule>

正如预期的那样,这不起作用。我尝试了很多我发现的东西,但没有找到任何解决方案。

不需要为此使用P或代理,只需在内部重写如下:

RewriteEngine On

RewriteRule ^(\d{18})/?$ /? [L,QSA]