© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
1 reply
trustie

❔ IIS urlrewrite not working

I have a simple web.config for an index.html page like this:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Redirect to /foo/" stopProcessing="true">
          <match url="^foo/(.*)" />
          <action type="Redirect" url="/foo/" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
    <defaultDocument>
      <files>
        <clear />
        <add value="index.html" />
      </files>
    </defaultDocument>
  </system.webServer>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Redirect to /foo/" stopProcessing="true">
          <match url="^foo/(.*)" />
          <action type="Redirect" url="/foo/" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
    <defaultDocument>
      <files>
        <clear />
        <add value="index.html" />
      </files>
    </defaultDocument>
  </system.webServer>
</configuration>


If I navigate to https://example.com/foo/REMOVE_ME then I get a 404 because /foo/REMOVE_ME is not a valid resource.
I feel like this rewrite is very simple and should be correct, but I'm clearly missing something. Any ideas?

Note, this is on a web app on my site. So the site is example.com and the web app is foo. IIS treeview looks like this:
server
  > application pools
  > sites
    > example.com
      > foo
        index.html
        web.config
server
  > application pools
  > sites
    > example.com
      > foo
        index.html
        web.config
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ wwwroot only working in IIS express, not http
C#CC# / help
3y ago
✅ IIS?
C#CC# / help
2y ago
✅ iis problem
C#CC# / help
2y ago
iis index.html
C#CC# / help
3y ago