[英]htaccess RewriteRule to Turkish Characters
I use htaccess file to redirect search queries. 我使用htaccess文件重定向搜索查询。
RewriteRule ^search/([a-zA-Z0-9\-\s]+)$ search.php?q=$1 [L,NC]
This works well for English letters and spaces. 这对于英文字母和空格非常有效。
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.
I need this to work with this characters too: "+ ş ö ç ğ ü Ş Ö Ç Ğ Ü" 我也需要与此字符一起使用:“ +şöçğüÖÇĞÜ”
Any suggestions? 有什么建议么?
You can't create a range to cover unicode characters, but you could change the regex to be a bit more lax: 您无法创建覆盖Unicode字符的范围,但可以将正则表达式更改为更宽松:
RewriteRule ^search/([^/_.]+)$ search.php?q=$1 [L,NC]
Or, if you need to specify ranges, you may be able to do something like: 或者,如果您需要指定范围,则可以执行以下操作:
RewriteCond %{THE_REQUEST} \ /+search/(%[89A-F][0-9A-Z]|[A-Z0-9+-]|%20)+ [NC]
RewriteRule ^search/([^/_.]+)$ search.php?q=$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.