【发布时间】:2016-04-15 00:34:41
【问题描述】:
我需要以特殊方式编辑 htaccess 以使所有请求(即 http://www.example.com/supermega.plist 或 http://www.example.com/ultraturbo.plist)将由一个 index.php 重定向和生成。在 index.php 中,我还想读取 plist 文件名。
谢谢
【问题讨论】:
标签: php .htaccess redirect friendly-url
我需要以特殊方式编辑 htaccess 以使所有请求(即 http://www.example.com/supermega.plist 或 http://www.example.com/ultraturbo.plist)将由一个 index.php 重定向和生成。在 index.php 中,我还想读取 plist 文件名。
谢谢
【问题讨论】:
标签: php .htaccess redirect friendly-url
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
您可以在$_GET 中访问filename 和ext:
print_r($_GET);
/* output
Array
(
[filename] => somefilename
[ext] => plist
)
*/
【讨论】: