简体   繁体   中英

how do i allow space in regex in mod_rewrite engine

i have a regex that i want it to allow white spaces. this regex i am using is in the .htaccess file. whenever i put the \s it makes the whole regex not work

what can i do to make it allow white spaces and work?

this is my regex:

([a-zA-Z0-9_-]+)\/?$

RewriteRule ^(?!profile|home|recieved|search|ajaxsearch|sent|favorites|deletemessage|favorite|replypopup|deletereply|Editprofile|changepass|followingsystem|checkFollowers|block|report|logout|login|register|forgotpassword|resetpassword|twitterapi|index|manage)([a-zA-Z0-9_-]+)\/?$ ./searchusers.php?search=$1 [L]

this is my full rewrite rule, when i put \s it doesn't work

Have your rule like this:

RewriteRule ^(?!profile|home|recieved|search|ajaxsearch|sent|favorites|deletemessage|favorite|replypopup|deletereply|Editprofile|changepass|followingsystem|checkFollowers|block|report|logout|login|register|forgotpassword|resetpassword|twitterapi|index|manage)([^/]+)/?$ ./searchusers.php?search=$1 [L,QSA,NC]

Here [^/] is negated character class that matches any character except / and it will match whitespace as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM