【问题标题】:How to redirect all .plist file requests to index.php如何将所有 .plist 文件请求重定向到 index.php
【发布时间】:2016-04-15 00:34:41
【问题描述】:

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

谢谢

【问题讨论】:

    标签: php .htaccess redirect friendly-url


    【解决方案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

    您可以在$_GET 中访问filenameext

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

    【讨论】:

    • 我有一些错误。再试一次。
    • 你是王者!有用!我想添加投票,但我没有足够的声誉;(
    • 别担心。您的问题已解决,这比投票更重要。 ;)
    猜你喜欢
    • 2016-11-30
    • 1970-01-01
    • 2012-12-07
    • 1970-01-01
    • 2013-10-26
    • 1970-01-01
    • 2015-04-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多