问题
I had wrote URL rewrite Rule:
<match URL="^([_0-9a-z-]+)/([_0-9a-z-]+)/([_0-9a-z-‘!@#$%^*()!~`\."]+)"/>
But there are some Chinese characters in my URL like:
'http://www.ilanbio-international.com/News/4443/中国陕西西安---渭南验室奠基石庆典'
Which is not support by this rule. So how can I support Chinese characters through URL rewriting?
回答1:
Just add this:
<match url="^([_0-9a-z-]+)/([_0-9a-z-]+)/([_0-9a-z-‘!@#$%^*()!~`\."\u4e00-\u9fa5]+)"/>
In place of this:
<match URL="^([_0-9a-z-]+)/([_0-9a-z-]+)/([_0-9a-z-‘!@#$%^*()!~."]+)"/>
Then your problem will solved.
回答2:
Thanks for the useful question and answer!
Just adding here for anybody has the same question but looking for an answer for the Arabic Unicode characters (0600–06FF, 255 characters)
instead, then it is as follows:
<match url="^([_0-9a-z-]+)/([_0-9a-z-]+)/([_0-9a-z-\u0600-\u06FF]+)"/>
回答3:
Search for the unicode of the characters here (if you are not using simplified chinese please search for YourLanguage unicode table
on google.
if you want to write 丈
(this is the fifth character in the table i linked you to) you need to write \u4E08
in which 4E08 is the unicode.
so 中国陕西西安
translates to \u4E2D\u56FD\u9655\u897F\u897F\u5B89
.
.htaccess rules use RegEx for matching.
regexr with example
回答4:
You will have to create a custom provider for URL rewrite and replace these Chinese characters with normal characters
refer http://www.iis.net/learn/extensions/url-rewrite-module/developing-a-custom-rewrite-provider-for-url-rewrite-module
来源:https://stackoverflow.com/questions/33015257/allow-chinese-chracters-in-url-rewriting