Parse question mark as normal character after mod_rewrite(mod_rewrite 后将问号解析为普通字符)
问题描述
所以这可能听起来很奇怪,但是我目前有 mod_rewrite 设置来传递 2 个变量.
So this may sound weird, however I currently have mod_rewrite set-up to pass 2 variables through.
RewriteRule ^profiel/(.*)$ index.php?p=profiel&user=$1
在第二个变量 (&user=) 中,它传递一个用户名,该用户名是通过 PHP 中的 GET 检索到的.但是,某些用户名中可能带有问号.但是,如果是这种情况,问号将不会传递给 GET 变量.(例如:www.example.com/profiel/whoami?"最终只是whoami"而不是whoami?")
In the second var (&user=), it passes a username which is retrieved through GET in PHP. However, some of the usernames can have question marks in them. However if this is the case, the question mark won't be passed to the GET variable. (For example: "www.example.com/profiel/whoami?" ends up as just "whoami" instead of "whoami?")
老实说,我不知道如何解决这个问题.任何帮助都会很棒!
I honestly don't know how to solve this problem. Any help would be great!
推荐答案
您可以通过直接从 THE_REQUEST
变量中捕获您的值来使用此规则:
You can use this rule by capturing your values directly from THE_REQUEST
variable:
RewriteEngine On
RewriteCond %{THE_REQUEST} /(profiel)/(S+)s [NC]
RewriteRule ^profiel/ index.php?p=%1&user=%2 [L,NC]
这篇关于mod_rewrite 后将问号解析为普通字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:mod_rewrite 后将问号解析为普通字符
基础教程推荐
- 使用 PDO 转义列名 2021-01-01
- PHP 守护进程/worker 环境 2022-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- HTTP 与 FTP 上传 2021-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01