【问题标题】:Passing $_GET variables in virtual sub directory url在虚拟子目录 url 中传递 $GET 变量
【发布时间】:2015-11-09 05:18:18
【问题描述】:

我对 php 和服务器端脚本很陌生。我有这个 URL `example.com/category/catname 其中 catname 目录使用 .htaccess 重写规则处理

^category/([A-Za-z0-9-]+)?$    category.php?type=$1    [NC,L]

但是当我使用分页变量时

example.com/category/catname?page=2

我无法在此访问 $_GET['page'] 变量。请帮忙。

【问题讨论】:

标签: php .htaccess mod-rewrite


【解决方案1】:

如果需要,我使用自定义函数来获取这些变量。

function process_requests(){
    $orig_URI = $_SERVER['REQUEST_URI'];
    list($null, $requests) = explode("?", $orig_URI);
    //cycle through our requests
    parse_str($requests, $res);
    return $res;
}

并像这样使用它:$requests = process_requests();

像这样访问项目:$requests['page'];

【讨论】:

    猜你喜欢
    • 2015-02-06
    • 1970-01-01
    • 2015-08-30
    • 1970-01-01
    • 2015-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-13
    相关资源
    最近更新 更多