开发者

How can I modify regular expression

How can I modify regular expression so it can also accept + in my URL

see: http://awakeningwithin.simpletix.com/Search/Lorem+/ ... error

if your remove the symbol: http://awakeningwithin.simpletix.com/Search/Lorem/ ... it works.

<rule name="Rewrit开发者_开发知识库eSearch" stopProcessing="true"> 
    <match url="^Search/([_0-9a-z-]+)" /> 
    <action type="Rewrite" url="Search.aspx?term={R:1}" /> 
</rule>


The plus + character in URL means SPACE (the same as %20).

1. Based on the above try this one: ^search/([-_0-9a-z\+ ]+)

2. If you see 404 error like this:

HTTP Error 404.11 - Not Found

The request filtering module is configured to deny a request that contains a double escape sequence.

  • go to IIS Manager, open Request Filter module (global .. or the one for specific site)
  • choose Edit Feature Settings on side column (or via context menu)
  • tick Allow double escaping

or use this code (place somewhere in web.config in website root folder):

<system.webServer>
    <security>
        <requestFiltering allowDoubleEscaping="true" />
    </security>
</system.webServer>

If #1 does not work, then do #1 AND #2.

TESTED on IIS 7.5 -- works fine.


You can use

 <match url="^Search/([_0-9a-z+-]+)" /> 

I simply added the + to the allowed characters. Note that the - must still be at the very end of the character set, since z-+ has special meaning there (all characters between z and plus... whatever that means).


How about adding "+" to the list of acceptable chars:

([+_0-9a-z-]+)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜