1

Hi there I am attempted to do a proper IIS rewrite utilizing the IIS manager credentials my hosting provider has given me. I have no experience with this and the articles I have read online so far have not been too helpful.

Here is the scenario: I have an ASP.net MVC 5 website (reallylongmaindomain.com, for ease of reading) that physically has the files uploaded to it. It is secured with an SSL certificate. The literature we are handing out has a shorter domain (not a URL-shortened domain) that we will call shortdomain.com, which does not have any files. However, if you navigate to shortdomain.com, you get an SSL domain name mismatch error (ERR_CERT_COMMON_NAME_INVALID to be precise). This is what I need to avoid.

In comes the IIS manager. I have successfully logged in to the system and added a URL Rewrite. This is the rule I have: (http(s)?://)?(www.)?shortdomain.com. This handles any http/https and/or www that the user may put in the address bar. The action properties are set to "Redirect" (Permanent 301) and the Redirect URL is set to https://reallylongmaindomain.com, but I am still getting the SSL certificate error and the URL in the window is still shortdomain.com.

I am sure I am just missing a simple thing or two. Do I also need to add the rule into my Web.Config file? I was under the impression the IIS manager rules superseded the Web.Config rules. EDIT: The rule was added to my web.config, here it is:

    <rewrite>
        <rules>
            <rule name="site redirect" stopProcessing="true">
                <match url="(http(s)?://)?(www.)?shortdomain.com" />
                <action type="Redirect" url="https://reallylongmaindomain.com" />
            </rule>
        </rules>
    </rewrite>

Thanks!

0

Turns out this is the rule I was looking for:

<rewrite>
    <rule name="redirect" stopProcessing="true">
        <match url=".*" />
        <conditions>
            <add input="{HTTP_HOST}" pattern="^(.*)?shortdomain.com" />                 
        </conditions>
        <action type="Redirect" url="https://reallylongmaindomain.com/{R:0}" />
    </rule>
</rewrite>

After applying this rule, navigating to shortdomain.com resolves perfectly fine to https://reallylongmaindomain.com.

Hopefully this helps someone else out!

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.