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)
答案 0 :(得分:2)
将\w
更改为[^/]
,以便您可以匹配空格而不是斜线。在重写规则中的模式匹配之前,URI中的编码空间将被解码:
RewriteRule ^([^/]+)(?:/[^/]+)?/?$ load.php?q=$1 [L,QSA]
如果字符串在NE
脚本中以%20
结尾,您可能还想在方括号中添加load.php
标记。