Php htaccess将规则重写为土耳其语字符
我使用htaccess文件重定向搜索查询Php htaccess将规则重写为土耳其语字符,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我使用htaccess文件重定向搜索查询 RewriteRule ^search/([a-zA-Z0-9\-\s]+)$ search.php?q=$1 [L,NC] 这适用于英文字母和空格 http://localhost:8080/search/stack%20over%20flow OK http://localhost:8080/search/stack-over-flow OK http://localhost:8080/search/stack+over+flow F
RewriteRule ^search/([a-zA-Z0-9\-\s]+)$ search.php?q=$1 [L,NC]
这适用于英文字母和空格
http://localhost:8080/search/stack%20over%20flow OK
http://localhost:8080/search/stack-over-flow OK
http://localhost:8080/search/stack+over+flow FAIL
http://localhost:8080/search/%C5%9Ftack%C3%B6verfl%C3%B6w (ştaköverflöw) FAIL
The requested URL /search/ştacköverflöw was not found on this server.
http://localhost:8080/search/%C3%B6z%20%C5%9Fan (öz şan) FAIL
The requested URL /search/öz şan was not found on this server.
我也需要这个来处理这些角色
有什么建议吗?您不能创建一个覆盖unicode字符的范围,但可以将正则表达式更改为更宽松一点:
RewriteRule ^search/([^/_.]+)$ search.php?q=$1 [L,NC]
或者,如果需要指定范围,可以执行以下操作:
RewriteCond %{THE_REQUEST} \ /+search/(%[89A-F][0-9A-Z]|[A-Z0-9+-]|%20)+ [NC]
RewriteRule ^search/([^/_.]+)$ search.php?q=$1 [L]