We help IT Professionals succeed at work.
Get Started

exclude folders from a rewrite rule in IIS 7

4,688 Views
Last Modified: 2012-05-12
Hi,

I have a site that needs url rewriting. I already managed to get the following working:

* www.atlanta.com/sounddesign --> rewritten as --> www.atlanta.com/?category=sounddesign
* www.atlanta.com/sounddesign/1234 --> rewritten as --> www.atlanta.com/?category=sounddesign&item=1234

My problem is that the website relies on css ans js files that are located in the directories /js en /css on the same webroot, so I need to exclude these in the rules or these links also get rewritten unintentionally.
In short, I need to achieve this:

* www.atlanta.com/js/ --> not rewritten
* www.atlanta.com/css/ --> not rewritten

I've been experimenting with this for quite some time now, but can't get it right.
Attached you'll find my web.config file.

Any help is highly appreciated!
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <outboundRules>
                <preConditions>
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                    </preCondition>
                </preConditions>
            </outboundRules>
            <rules>
                <rule name="RedirectUserFriendlyURL1" enabled="true" stopProcessing="true">
                    <match url="([_0-9a-z-]+)" />
                    <conditions>
                        <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/?category={R:1}" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Open in new window

Comment
Watch Question
DevOps Manager
Top Expert 2011
Commented:
This problem has been solved!
Unlock 2 Answers and 4 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE