简体   繁体   中英

URL Redirect web.config

I have the following URL

https://www.abcsite.com/?data=w35VTqIaVXWfi4GmESj8EGCG1cdF2aT%2BUF3D?utm_source=external%20system&utm_campaign=external%20system&utm_medium=EX.com&utm_content=MMB

which has extra ? at the end. which I Would like to remove and replace with "&"

I am using following rule but it is not working. can you review this and tell me what I am doing wrong.

 <rewrite>
  <rules>
    <rule name="fixdata" stopProcessing="true">
      <match url="\?(.*)\?(.*)$"  ignoreCase="false" />
      <action type="Redirect" redirectType="Permanent" url="http://www.example.com/{R:1}&{R:2}" />
    </rule>
  </rules>
</rewrite>  

Thanks.

You rule should be like this:

<rule name="fixdata" stopProcessing="true">
    <match url=".*" />
    <conditions>
        <add input="{QUERY_STRING}" pattern="(.*)\?utm_source(.*)$" />
    </conditions>
    <action type="Redirect" url="{R:0}?{C:1}&amp;utm_source{C:2}" appendQueryString="False" />
</rule>

Your rule didnt work, because <match url= contains path without query string. You need to create additional condition to match query string with your regexp pattern

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM