0

I am useing a web.config file to make a rewrite to my website

The only rule is

<rule name="id">
<match url="([_0-9a-z-]+)" />
<action type="rewrite" url="default.asp?id={R:1}">
</rule> 

The code working fine,but the problem is when The page call images or files like CSS or JavaScript from another folder it doesn't work at all. How can I avoid that problem?

Dan
  • 3
  • 1

1 Answers1

0

You need to add some conditions to your rule to work only when the url does not correspond to a file or directory. This is one of the keys of URL Rewriting.

<rule name="id">
    <match url="([_0-9a-z-]+)" />
    <action type="Rewrite" url="default.asp?id={R:1}" />
    <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
</rule>

enter image description here

Kul-Tigin
  • 16,728
  • 1
  • 35
  • 64