mod_rewrite的重写规则来处理HTML实体 [英] mod_rewrite RewriteRule to handle HTML Entities

查看:161
本文介绍了mod_rewrite的重写规则来处理HTML实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些原因,我们recieving一堆入站流量对包含HTML实体的URL。

For some reason, we recieving a bunch of inbound traffic on URLs that contain HTML entities.

例如

http://www.ourdomain.com/index.php?key1=value1&key2=value2

我想创建一个重写规则来代替这些HTML实体(特别是&放大器;放大器;与&安培;),和着人们对校正后的地址

I want to create a RewriteRule to replace these HTML entities (specifically & with &), and forward people on to the corrected address.

我在尝试这些:

重写规则和放大器;放大器; &安培; [R =永久]

重写规则和放大器;放大器; &安培;

但什么也没发生。

(顺便说一句,我知道这是解决别人的问题一个可怕和危险的方式,但我只需要完成它。暂时)

(BTW. I know this is a horrible and dangerous way to solve someone else's problem, but I just need to get it done. temporarily)

感谢您的帮助...

推荐答案

这应该做的伎俩;

RewriteEngine On
RewriteCond %{QUERY_STRING} (.*)&(.*)
RewriteRule .* /index.php?%1&%2 [N,R=301]

这本质上说;


  • 有一个&放大器;放大器; 在查询字符串

  • 如果是的,与一切之前和之后,然后连同他们夹在&安培;

  • 在规则中的 N 标志有效地写着继续这样做,直到条件不再对比赛作

  • Is there an & in the query string?
  • If yes, match everything before and after it, then sandwich them together with an &
  • The N flag in the rule effectively says 'keep doing this until the condition no longer makes a match'

查看 mod_rewrite的文档,其中的的RewriteCond 和的规则标志的。

这篇关于mod_rewrite的重写规则来处理HTML实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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