php - .htaccess URL 重写不适用于 "?"符号作为数据

标签 php apache .htaccess url-rewriting symbols

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

7dDirSxvHg9h6Z4gHX9oo29SuN8k4dXV?Authority=000000000000000000000000000070816609&Status=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 标志:

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]

关于php - .htaccess URL 重写不适用于 "?"符号作为数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49681295/

相关文章:

java - ColdFusion 实体加载过滤条件生成 java 错误

Apache AddType text/css .css 被忽略

java - 通过 Android 模拟器和 xampp 服务器连接到本地主机

php - 在网站上工作的独立自由职业者的专业发展部署策略?

linux - 如何为所有请求添加 ~username 前缀?

php - httpd 不会以为 php 添加的行开始

php - 如何从地址中删除index.php,同时通过fastcgi将请求重定向到index.php?

PHP - 用户登录后显示信息的问题

wordpress - 301 使用新结构重定向多个目录

php 与 htaccess 重定向