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

时间:2016-01-10 18:12:55

标签: php .htaccess redirect friendly-url

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

由于

1 个答案:

答案 0 :(得分:1)

RewriteEngine On

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

在以下网址中:

http://127.0.0.1/somefilename.plist

您可以访问filename中的ext$_GET

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