IIS URL重写模块 - 加上添加字符时出错

时间:2017-02-20 11:31:07

标签: regex mod-rewrite iis url-rewriting query-string

我在iis url重写模块中使用+(加上添加)字符时遇到问题。

我需要改写:

http://www.example.com/search/test1+test2

http://www.example.com/search/?q=test1+test2

Url重写模块基本解决方案不起作用并抛出404错误:

模式: ^搜索/([^ /] +)/?$

重写网址:搜索/?q = {R:1}

=============================

我尝试添加另一个参数,但我再次抛出404错误:

模式: ^搜索/([^ /] +)\ +([^ /] +)/?$

重写网址:搜索/?q = {R:1} + {R:2}

=============================

这个替代解决方案例如有效:

模式: ^搜索/([^ /] +) - ([^ /] +)/?$

重写网址:搜索/?q = {R:1} + {R:2}

有什么问题?

提前致谢

1 个答案:

答案 0 :(得分:1)

我认为你不需要开头的^

模式:search/([^/]+)/?$

重写网址:search/?q={R:1}