问题
Right now I have a redirect set up like this
<rule name="EN" stopProcessing="true">
<match url="en/(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="$1$2" />
</rule>
However, it is not working properly. I'm trying to get it to be so when a user types in www.mysite.com/en/anything.aspx That it redirects to www.mysite.com/anything.aspx
I have a feeling I've set something up wrong, maybe incorrect syntax.
Any help would be greatly appreciated!!
回答1:
Does your condition get a match so you know that part is OK? I dont think you use $1 $2 but {R:1} {R:2} etc.
<action type="Redirect" url="{R:1}" />
I have not tested this, but I would try this:
<rule name="EN" stopProcessing="true">
<match url="en/(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:1}" />
</rule>
来源:https://stackoverflow.com/questions/8124987/redirect-in-iis-using-variables-12