0

I would like to redirect the below old URL:

https://domain1.xyz.com/content/images/1ca9551bc00357f63c608b5d90ca7c4652187487.png

to the new URL:

https://domain2.xyz.com/originalfiles/1ca9551bc00357f63c608b5d90ca7c4652187487.png

My web.config file has below configuration but I cannot get it to work:

<rewrite>
       <rules>
          <rule name="Rewrite Images to CDN" stopProcessing="true">
                <match url="(.*)" />
                <action type="Redirect" url="https://domain2.xyz.com/originalfiles/{C:1}" appendQueryString="true" redirectType="Permanent" />
                <conditions>
                   <add input="{HTTP_HOST}" pattern="domain1.xyz.com" />
                   <add input="{URL}" pattern="content/images/(/*.*)" />
                </conditions>
         </rule>
       </rules>
</rewrite>

Above configuration redirects to this URL which is incorrect:

https://domain2.xyz.com/originalfiles/content/images/1ca9551bc00357f63c608b5d90ca7c4652187487.png

1 Answer 1

1

Please try the following rule:

<rewrite>
       <rules>
          <rule name="Rewrite Images to CDN" enabled="true" stopProcessing="true">
                <match url="content/images(.*)" />
                <conditions>
                   <add input="{HTTP_HOST}" pattern="domain1.xyz.com" />
                </conditions>
                <action type="Redirect" url="https://domain2.xyz.com/originalfiles{R:1}" />
           </rule>
        </rules>
</rewrite>
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much. This worked for me. Also I realized that every time I made a change in the web.config file, IIS or browser seem to have a Cached response and the redirect did not work. I tried opening up the old Image URL in an incognito browser window and it worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.