Using the IIS URL Rewrite Module I am trying rewrite an incoming Url from /en/开发者_运维技巧page.aspx to /en/page/index.aspx
Using regular expression I am checking that the string ends with .aspx
^.*(.aspx)$
Currently in capture group I am getting
/en/page.aspx
How can i only capture /en/page part?
Further down the line I will rewrite the Url as follows:
{R:0}/index.aspx
To match without capturing you can use the ?:
pattern, like (?:\.aspx)
. However, to suit your redirection needs you may want to use the following expression:
^(.*)(\.aspx)$
So that {R:1}
will point to exactly what you need. Also note you need to escape the dot, so that the expression will match the dot character and not every other one.
Change how you capture matches...
^(.*?)(\.aspx)$
When going through the matches collection, the matches should be the following:
index 0 should be the whole url
index 1 should be /en/page
index 2 should be .aspx
精彩评论