1

I am looking for a solution to an issue that I have. In my scenario, I have a CName record provided by a client, www.example.com. When the user types in www.example.com, I need to redirect them to www.answer.com, but still maintain their URL. When I try simple cname redirects, the referring URL is still in the address bar, and IIS does not know how to load my application. What is the best way to accomplish masking in this format?

1 Answer 1

2

CNAMEs are not really redirects - they're a DNS record type that allows you to easily manage multiple domains/subdomains pointing to the same IP address, without having to change every one them if the IP changes.

So using a CNAME, as far as IIS is concerned, is no different to just a normal A record.

What you need is an HTTP redirect. This IIS reference page explains how to install the required module, and the syntax to use in your ApplicationHost.config file. Alternatively, the URL Rewrite module will give you more flexibility and you might already have it installed anyway.

If you're using a framework for your application, it may already have features built into it for redirection, so if that's the case make sure you check the docs for your framework before doing it manually.

Also, unless this is a temporary redirect, you'll want to set the HTTP response code to 301 to inform browsers and search engine crawlers that this redirect will always be in place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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