在mod_rewrite之后将问号解析为正常字符 [英] Parse question mark as normal character after mod_rewrite

查看:128
本文介绍了在mod_rewrite之后将问号解析为正常字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  RewriteRule ^ profiel 

所以这听起来很奇怪,但是我现在有mod_rewrite设置来传递2个变量。 /(.*)$ index.php?p = profiel& user = $ 1

在第二个变量(& user =),它传递一个通过PHP中的GET检索的用户名。但是,其中一些用户名可能带有问号。但是,如果是这种情况,问号将不会传递给GET变量。 (例如:www.example.com/profiel/whoami?最终只是whoami而不是whoami?)



我老实说不要知道如何解决这个问题。任何帮助都会很棒!

解决方案

您可以通过直接从 THE_REQUEST 变量:

  RewriteEngine On 

RewriteCond%{THE_REQUEST} /(profiel )/(\ S +)\s [NC]
RewriteRule ^ profiel / index.php?p =%1& user =%2 [L,NC]


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

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!

解决方案

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之后将问号解析为正常字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆