RewriteCond中的空间 [英] Space in RewriteCond

查看:64
本文介绍了RewriteCond中的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下规则:

RewriteCond %{QUERY_STRING} ^products=Product Name$
RewriteRule ^buyonline\.php$ http://www.example.com/shop/5-Product-Name.html? [L,R=301]

我需要重定向已经存在于Google中的链接,但是由于没有模式,因此我不能仅使用例如^products=(.*)$.

I need to redirect links existing in Google already, however there is no pattern so I can't just use e.g. ^products=(.*)$.

如果参数没有空格,则上面的代码可以正常工作.我尝试了很多组合,例如\ s双引号等.

Code above works fine if parameter has no spaces. I have tried lots of combinations like \s doublequotes, etc, etc.

推荐答案

空间作为%20传输到Apache服务器,并且%也需要转义.

Space is transmitted as %20 to Apache server and % needs to be escaped as well.

这应该有效:

RewriteCond %{QUERY_STRING} ^products=Product\%20Name$
RewriteRule ^buyonline\.php$ http://www.example.com/shop/5-Product-Name.html? [L,R=301]

这篇关于RewriteCond中的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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