开发者

Mod rewrite, need to allow only letters, numbers and white spaces

开发者 https://www.devze.com 2023-04-04 04:59 出处:网络
Since I need to allow my users, to search strings with white spaces, I need to modify this rewrite rule (lighttpd engine).

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",

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

Thank you in advance.


Whitespace in regex is \s

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

or

"^/(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"

See the basics on lighttpd wiki and complete regex reference.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号