On a website I help support, they have country based websites (en-de, en-au) which they want to shut off a redirect to the main two which are en-gb and en-us.
The website runs on a Microsoft server and tbh I am more Apache/PHP based. I have set up a redirect currently which redirect the en-au url and takes them to the same url on en-gb. So if they are on en-au/some-url it will send them to en-gb/some-url.
My only problem is if the same url does not exist for en-gb. Is there a way on IIS to set up a fallback? So if it leads to a 404 from the redirect it sends them to the homepage instead?
Add another url rewrite to handle the 404's, below will direct all 404's back to your homepage.
<rewrite>
<rules>
<rule name="Redirect404" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" url="/YourHomePage.html" />
</rule>
</rules>
</rewrite>
You can also add custom error pages to handle the 404's
http://www.iis.net/configreference/system.webserver/httperrors/error