Mod重写,只需要允许字母,数字和空格 [英] Mod rewrite, need to allow only letters, numbers and white spaces

查看:81
本文介绍了Mod重写,只需要允许字母,数字和空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我需要允许我的用户搜索带有空格的字符串,因此我需要修改此重写规则(lighttpd引擎).

Since I need to allow my users, to search strings with white spaces, I need to modify this rewrite rule (lighttpd engine).

"^/(results)/(query)/([0-9a-zA-Z_]+)$" => "index.php?action=results&query=$3",

仅允许字母,数字和空格(我想只需要那些字母,数字和空格即可从MySQL搜索某些数据?).

To allow only letters, numbers and white spaces (I guess only those are needed to search some data from MySQL?).

谢谢.

推荐答案

正则表达式中的空格为\s

Whitespace in regex is \s

"^/(results)/(query)/([0-9a-zA-Z_\s]+)$" => "index.php?action=results&query=$3"

"^/(results)/(query)/([\w\d\s_]+)$" => "index.php?action=results&query=$3"

如果需要-号,它必须是范围中的第一个

If - sign needed, it must be the first in range

"^/(results)/(query)/([-0-9a-zA-Z_\s]+)$" => "index.php?action=results&query=$3"

请参阅 lighttpd Wiki 的基础知识,并完成正则表达式

See the basics on lighttpd wiki and complete regex reference.

这篇关于Mod重写,只需要允许字母,数字和空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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