Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9184085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:57:33+00:00 2026-06-17T18:57:33+00:00

I’m attempting to write a rewrite rule for the following scenario. User attempts to

  • 0

I’m attempting to write a rewrite rule for the following scenario.

User attempts to load this picture:

domain.com/images/folder/picture.jpg

and instead, I need it to load:

cdn.domain.com/images/folder/picture.jpg.

Here’s what I have that isn’t working:

<rule name="CDN rewrite for Images">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="domain.com" />
        <add input="{REQUEST_URI}" pattern="^/images/folder/(.*)$" />
    </conditions>
    <action type="Rewrite" url="cdn.domain.com/images/folder/{C:1}" />
</rule>

UPDATE: Adding additional info. Most pictures are being served up from Joomla so while the root of the domain is something like domain.com, most images are input with a src=”/images/folder/picture.jpg” Not quite sure how this is affecting the rewrite, but none of the options on cheesemacfly’s answer below, are working…

UPDATE2: While cheesemacfly was unable to help me in my particular circumstances, I awarded him the bounty and marked his answer as the accepted one because he went above and beyond to try to help me in chat. Hopefully his answer will help someone with rewrites on IIS.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:57:35+00:00Added an answer on June 17, 2026 at 6:57 pm

    EDIT:

    To be able to rewrite (and not only redirect) urls to outside websites, you need to install the Application Request Routing module and enable the proxy mode.

    To do so:

    1. Download and install the module
    2. Open your IIS management console (inetmgr)
    3. Select Your server node
    4. Double click on Application Request Routing Cache:
      ARR
    5. Click on Server Proxy Settings on the Actions pane (right of the screen)
    6. Check the box Enable proxy and click on Apply
      proxy

    The second step is about setting up your rules.

    If you want your rewrite to be based on the path then use the following code:

    <rewrite>
      <rules>
        <rule name="Rewrite to cdn domain">
          <match url="^images/folder/(.+)$" />
          <action type="Rewrite" url="http://cdn.domain.com/images/folder/{R:1}" />
        </rule>
       </rules>
    </rewrite>
    

    Or if you keep the same folder architecture on the second website you can simplify as follow:

    <rewrite>
      <rules>
        <rule name="Rewrite to cdn domain">
          <match url="^images/folder/(.+)$" />
          <action type="Rewrite" url="http://cdn.domain.com/{R:0}" />
        </rule>
       </rules>
    </rewrite>
    

    If you want to catch only the files ending with a specific extension (let’s say images):

    <rewrite>
      <rules>
        <rule name="Forward to cdn domain">
          <match url="^images/folder/.+\.(?:jpg|bmp|gif)$" />
          <action type="Rewrite" url="http://cdn.domain.com/{R:0}" />
        </rule>
      </rules>
    </rewrite>
    

    Please refer to: http://www.iis.net/learn/extensions/url-rewrite-module/iis-url-rewriting-and-aspnet-routing (section “Which Option Should You Use?“)

    TIP:

    The best way to test your pattern is to use the IIS test pattern tool.

    At the root of your website -> URL Rewrite -> Create a blank rule -> click on test pattern:
    Pattern test

    If you don’t get the expected result, you can debug your rewrite using the Failed Request Tracing tool

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am using JSon response to parse title,date content and thumbnail images and place
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.