2011-04-01 10 views
1

をリダイレクトします。条件付きクエリ文字列私は別のドメイン名へのクエリ文字列を持っている要求をリダイレクトしようとしている

私は短いURLを持っています。http://short.urlhttp://short.url?hellohttp://long.url/?helloにリダイレクトしたいと思います。したがって、クエリ文字列はリダイレクトによって保持されなければなりません。物事をもっと複雑にするために、私はhttp://short.url?hello,hello2からhttp://long.url/advanced.aspx/?hello,hello2に再配布したいと思います。ここで

は、私が今持っているルールは

<rewrite> 
    <rules> 
     <rule name="test" patternSyntax="ECMAScript" stopProcessing="true"> 
      <match url="~/?\w+" /> 
      <action type="Redirect" url="http://long.url/?{R:0}" redirectType="Found" /> 
     </rule> 
    </rules> 
</rewrite> 

は、しかし、私はすべてのリダイレクトを見ていないです(唯一の私の質問の最初の部分を扱う)です。また、これを行うには良い方法がありますか?基本的に私はちょうどウェブサイトにクエリを渡すためのショートカットをセットアップしたい。これらは永久的なものではないので、redirectType="Found"を使用しています。

+0

FWIW、あなたはのHttpHandlerを書いて、あなたがやりたい(あるいは直接のGlobal.asaxを使用)するためにC#のコードで直接URLを操作することができ –

答えて

1

誰もがこれを行うために探している場合:

<rules> 
    <rule name="Basic" patternSyntax="ECMAScript" stopProcessing="true"> 
     <match url="\w*" /> 
     <action type="Redirect" url="http://longurl.com" redirectType="Found" /> 
     <conditions> 
      <add input="{QUERY_STRING}" pattern="\w+" /> 
      <add input="{QUERY_STRING}" pattern="\," negate="true" /> 
     </conditions> 
    </rule> 
    <rule name="Advanced" patternSyntax="ECMAScript" stopProcessing="true"> 
     <match url="\w*" /> 
     <action type="Redirect" url="http://longurl.com/advanced.aspx" redirectType="Found" /> 
     <conditions> 
      <add input="{QUERY_STRING}" pattern="^\w+(?=\,)" /> 
     </conditions> 
    </rule> 
</rules> 
関連する問題