使用变量($ 1 $ 2)在IIS中重定向 [英] Redirect in IIS using Variables ($1$2)

查看:323
本文介绍了使用变量($ 1 $ 2)在IIS中重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我有一个重定向设置像这样

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>

但是,不能正常工作。我试图让它如此时www.mysite.com/en/anything.aspx,用户在键入其重定向到www.mysite.com/anything.aspx~~V

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.

任何帮助将大大AP preciated !!

Any help would be greatly appreciated!!

推荐答案

请问您的病情得到了比赛,所以你知道的那部分就OK?
我不认为你用$ 1 $ 2,但{R:1} {R:2}等

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>

这篇关于使用变量($ 1 $ 2)在IIS中重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆