example.com/search/search+something I want to like this search but its not work
example.com/search/.htaccess
<Files .htaccess>
order allow,deny
</Files>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /search/
RewriteRule ^(w+)(?:/[^/]+)?/?$ load.php?q=$1 [L,QSA]
RewriteRule ^(w+)/[^/]+/[^/]+/([0-9]+)/?$ load.php?q=$1&p=$2 [L,QSA]
如何修复它…如果我像这样键入example.com/search/songs
,它就工作了。但在songs
之后添加一些带有空格或(+(的内容不起作用,并显示404页。。ex :(example.com/search/songs+video)
将w
更改为[^/]
,以便可以匹配空格,但不能匹配斜线。URI中的编码空间在被重写规则中的模式匹配之前会被解码:
RewriteRule ^([^/]+)(?:/[^/]+)?/?$ load.php?q=$1 [L,QSA]
如果字符串在load.php
脚本中以%20
结尾,您可能还需要在方括号中添加NE
标志。