Monday, March 5, 2018

IIS Rewrite using IIS Manager



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:



    










Thanks!


Answer



Turns out this is the rule I was looking for:
















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



Hopefully this helps someone else out!


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...