Share via


URL Rewrite excluding/fixing images, links, css

Question

Friday, July 16, 2010 6:37 PM

Guys,

 What is the simplest way to exclude images, css, javascript, links from rewriting. I'm rewriting http://mylink/34/234/Hello to http://mylink/content.aspx?u=34&p234&title=Hello.

I got the rewrite happening, but everything is broken including images, javascript all the links because all links and images have the rewritten url address as the base like http://mylink/34/234/hello/image.jpeg which it should be the root. Please help me out with this problem. I think URL rewrite should be smart enough to not rewrite the obvious image, css paths.

Please help.

All replies (3)

Wednesday, July 21, 2010 5:15 AM âś…Answered

Hi,

The simplest way should be add a is not a file condition:

                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    </conditions>

If anything is unclear, please update here.


Thursday, May 10, 2012 10:02 AM

 HI this same problem is with me too.I put the above code like this .But still it is not working.

  <rewrite>
      <rules>
        <rule name="Rewrite to article.aspx" stopProcessing="true">
          <match url="^content/([_0-9a-z-]+)" />
          <action type="Rewrite" url="content.aspx?page={R:1}" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          </conditions>
        </rule>
      </rules>

Any help?


Friday, February 1, 2013 8:21 AM

That didn't work for me. I used this code instead.

<Rules>
<rule name="Redirect  All Sites to Maitenance Pages" enabled="true"   stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_URI}" pattern="\.png|\.css|\.jpg" negate="true" />
</conditions>
<action type="Rewrite" url="maintenance.htm" appendQueryString="false" />
</rule>
</Rules>