Hy, I have this rewriteRule to change a /search?key=ok
to /search/ok
from a search bar
RewriteCond %{QUERY_STRING} key=([0-9a-zA-Z_-]+) [NC]
RewriteRule (.*) /search/%1? [R=302,L]
But when I search something with spaces like ok ko
it's just return /search/ok
.
What do I have to change to have /search/ok-ko
?
Thanks !
答案 0 :(得分:1)
您的正则表达式模式([0-9a-zA-Z_-]+)
仅匹配字母数字字符,您可以在模式中添加\s
以匹配Querystring中的空格字符
RewriteCond %{QUERY_STRING} key=([0-9a-zA-Z\s_-]+) [NC]
RewriteRule (.*) /search/%1? [R=302,L]