如何将所有 .plist 文件请求重定向到 index.php

How to redirect all .plist file requests to index.php

我需要以特殊方式编辑 htaccess,所有请求即 http://www.example.com/supermega.plist or http://www.example.com/ultraturbo.plist 将被重定向并由一个 index.php 生成。在 index.php 中,我还想读取 plist 文件名。

谢谢

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*)\.(plist)$ /index.php?filename=&ext= [L,QSA]

在以下 URL 中:

http://127.0.0.1/somefilename.plist

您可以在 $_GET 中访问 filenameext :

print_r($_GET);
/* output
Array
(
    [filename] => somefilename
    [ext] => plist
)
*/