dtiu94034 2013-03-05 10:15 采纳率: 0%
浏览 28
已采纳

mod_rewrite发送不正确的结果

My rewrite rule is the following:

RewriteRule ^groups/([0-9]+)/pg:([0-9]+);cr:(0|1);r:([a-z0-9-]+);rv:(0|1);eu:(0|1);fr:(0|1);de:(0|1);it:(0|1);ru:(0|1);es:(0|1);br:(0|1);la:(0|1);us:(0|1);au:(0|1)$ index.php?mod=groups&groups=$1&pg=$2&crossrealm=$3&realm=$4&reverse=$5&eu=$6&fr=$7&de=$8&it=$9&ru=$10&es=$11&br=$12&la=$13&us=$14&au=$15 [NC,L]

Which does the redirection successfully, however, the $_GET sent displays incorrect results:

$_GET:
array (size=16)
  'mod' => string 'groups' (length=6)
  'groups' => string '117' (length=3)
  'pg' => string '1' (length=1)
  'crossrealm' => string '1' (length=1)
  'realm' => string 'aegwynn' (length=7)
  'reverse' => string '0' (length=1)
  'eu' => string '1' (length=1)
  'fr' => string '0' (length=1)
  'de' => string '0' (length=1)
  'it' => string '0' (length=1)
  'ru' => string '1170' (length=4)
  'es' => string '1171' (length=4)
  'br' => string '1172' (length=4)
  'la' => string '1173' (length=4)
  'us' => string '1174' (length=4)
  'au' => string '1175' (length=4)

Does anyone have any ideas what might be causing this issue and how it can be fixed?

EDIT: The errors begin with the mod_rewrite part which starts at $10, i.e. &ru=. The rewritten URL returns correctly yet the actual one is http://localhost/index.php?mod=groups&groups=117&pg=1&crossrealm=1&realm=aegwynn&reverse=0&eu=1&fr=0&de=0&it=1&ru=1170&es=1171&br=1172&la=1173&us=1174&au=1175

  • 写回答

1条回答 默认 最新

  • drryyiuib43562604 2013-03-05 11:17
    关注

    mod-rewrite doesn't allow you to catch more than 9 parameters (from $1 to $9).

    In your case, $10 is readen as ($1)0, that's why you got '1170'.

    You should better send the entire requested URI and explode it with PHP :

      list(
        $_GET['mod'], 
        $_GET['groups'], 
        $_GET['pg'], 
        $_GET['crossrealm'], 
        $_GET['realm'], 
        $_GET['reverse'], 
        $_GET['eu'], 
        $_GET['fr'], 
        $_GET['de'], 
        $_GET['it'], 
        $_GET['ru'], 
        $_GET['es'], 
        $_GET['br'], 
        $_GET['la'], 
        $_GET['us'], 
        $_GET['au']
      ) = explode( '/', $_GET['params']);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 netty整合springboot之后自动重连失效
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击