【问题标题】:how to Pass query string in 404 error redirect through .htaccess?如何通过 .htaccess 在 404 错误重定向中传递查询字符串?
【发布时间】:2013-01-01 17:00:22
【问题描述】:

我有一个index.php 文件,它处理对服务器的所有请求。我以这种方式在.htaccess 中设置了 404 错误重定向:

ErrorDocument 404 /index.php

如果用户请求一个文件,比如page.php,那么它会被正确地重定向到index.php 页面。

当用户请求page.php?page=about, then my index.php is unable to retrieve the queryaboutusing$_REQUEST['page']`时出现问题。

如何使用$_REQUEST['page'] 通过index.php 获取查询about

【问题讨论】:

    标签: php .htaccess


    【解决方案1】:

    $_SERVER['REDIRECT_QUERY_STRING'] 可能包含您的查询字符串。

    试一试。

    <?php
        print_r($_SERVER['REDIRECT_QUERY_STRING']);
    ?>
    

    【讨论】:

    • 我可以将 $_SERVER['REDIRECT_QUERY_STRING'] 放入 $_SERVER["QUERY_STRING"] 吗?
    • thnaks,我可以修改 $_SERVER["QUERY_STRING"] :) thnaks 很多 :)
    • 另见parse_urlparse_str
    猜你喜欢
    • 2014-05-10
    • 2015-10-16
    • 1970-01-01
    • 1970-01-01
    • 2012-07-27
    • 2013-06-21
    • 2015-03-31
    • 1970-01-01
    相关资源
    最近更新 更多