Question

I have problem with redirect.
I have domain like:
example.com

and a few subdomain like
application.example.com
documents.example.com

It's hard to make a wildcard binding, so i want to do URL redirect in Default Web Site ;) If somebody make mistake in URL address like:
doduments.example.com - I want to redirect him to example.com

Here the case is more complicated, because i need do something similar, but for another domain:
example.pl
and subdomains
aplikacja.example.pl
dokumenty.example.pl

Was it helpful?

Solution

I did something like this ;)

            <rule name="*.example.pl" stopProcessing="true">
                <match url="(.*)" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{HTTP_HOST}" pattern="example\.pl$" />
                </conditions>
                <action type="Redirect" url="http://example.pl/" />
            </rule>
            <rule name="*.example2.pl" stopProcessing="true">
                <match url="(.*)" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{HTTP_HOST}" pattern="example2\.pl$" />
                </conditions>
                <action type="Redirect" url="http://example2.pl/" />
            </rule>

Far from perfection, but it works. I won't be able to filter domain in match url - i don't know why ;(

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top