Roffers
Roffers

Reputation: 701

Subdirectory to subdirectory UrlRewrite with filename

I'm trying to rewrite all requests from e.g /img/logo.svg to go to /dist/img/logo.svg

Any idea? I'm sure it's something obvious.

    <rule name="RewriteImgFolder" stopProcessing="true">
      <match url="^/img/(.*)" />
      <action type="Rewrite" url="/dist/img/{R:1}" />
    </rule>

Upvotes: 0

Views: 36

Answers (1)

Brando Zhang
Brando Zhang

Reputation: 28192

If your url is http://localhost/img/logo.svg, your url rewrite rule will not work.

You could remove the "/" in the match url.

More details, you could refer to below rules:

<rule name="RewriteImgFolder" stopProcessing="true">
  <match url="^img/(.*)" />
  <action type="Rewrite" url="/dist/img/{R:1}" />
</rule>

Upvotes: 1

Related Questions