我们使用IIS重写模块,如下所示
<rule name="RewriteSearch" stopProcessing="true">
<match url="^Search/([_0-9a-z+-]+)" />
<action type="Rewrite" url="CommonPages/Search.aspx?term={R:1}" />
</rule>http://www.tickettail.com/Search/NormalText123工作很好
但是..。
http://www.tickettail.com/Search/ราคัดมาใ
(我是泰国人)不会。如何修改匹配以允许外文?
谢谢
发布于 2013-01-18 13:40:21
要匹配的正则表达式只接受字符_、0到9、a到z、+和-。为了接受所有字符,您必须将正则表达式修改为例如(.+) (这接受任何字符,并且至少需要一个字符)。
其次,为了将任何字符正确地传递到搜索页面,您必须使用内置的{UrlEncode:{}}函数对该词进行URL编码。此外,确保您的页面可以处理和输出UTF-8。
以下规则起作用:
<rule name="RewriteSearch" stopProcessing="true">
<match url="^Search/(.+)" />
<action type="Rewrite" url="CommonPages/Search.aspx?term={UrlEncode:{R:1}}" />
</rule>https://stackoverflow.com/questions/14391825
复制相似问题