【问题标题】:.htaccess URL rewrite not work for "?" symbol as data.htaccess URL 重写不适用于“?”符号作为数据
【发布时间】:2018-09-15 19:16:52
【问题描述】:

我想通过 URL ($_GET) 将此字符串传递给我的 php 文件。

7dDirSxvHg9h6Z4gHX9oo29SuN8k4dXV?Authority=000000000000000000000000000070816609&状态=OK

这是我的 .htaccess 代码

RewriteEngine on
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/(.*)$    index.php?page=$1&$2=$3    [NC,L]
RewriteRule ^([A-Za-z0-9-]+)?$   index.php?page=$1   [NC,L]

但是当我打开这个网址时:

example.com/callback/Data/7dDirSxvHg9h6Z4gHX9oo29SuN8k4dXV?Authority=000000000000000000000000000070816609&Status=OK

var_dump 代码显示这个字符串:

array(2) { ["page"]=> string(8) "callback" ["Data"]=> string(32) "7dDirSxvHg9h6Z4gHX9oo29SuN8k4dXV" } 

后面有什么字符吗?符号被删除。我的代码的哪一部分不正确?

【问题讨论】:

  • 使用QSA 标志附加上一个查询字符串

标签: php apache .htaccess url-rewriting symbols


【解决方案1】:

如果您希望它保留在查询字符串中,您需要在重写时使用QSA 标志:

RewriteEngine on
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/(.*)$    index.php?page=$1&$2=$3    [NC,L,QSA]
RewriteRule ^([A-Za-z0-9-]+)?$   index.php?page=$1   [NC,L,QSA]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-23
    • 2019-05-26
    • 2018-08-24
    • 1970-01-01
    相关资源
    最近更新 更多