C
C#9mo ago
fenixblades

❔ 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
1 Reply
Accord
Accord9mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.