views:

2214

answers:

6

Our company has for many years had multiple domain names to protect our product name. When our webiste was first set up we had all these domain names resolving to on IP address which worked fine until now. We rewrote the site with ASP.NET MVC and now use Recaptcha. The Recaptcha keys are registered to "www.example.com" which is our main domain. We have other domains like "www.examples.com" and "www.ex-ample.com" that points to the same IP address. when someone comes to our site from the alternate domains, Recaptcha doesn't work because the keys aren't registered for that alternate domain. We would like to redirect eveything that comes in from "www.examples.com" to "www.example.com".

I have read that you can set up the sites in IIS and use a permanent redirect, but will this work if the domains all point to the same IP address?

We also have installed the Rewrite Module for IIS 7 because a lot of our pages moved when we switched to MVC. Is it possible to write a rule and if so how?

Is there a better alternative we should be using?

Any help to shine some light on this is greatly appreciated.

A: 

Just off the top of my head, you may want to look into DNS CNAME here.

Another possible solution is to set up a website in IIS with domain aliases for all of your other domains in place and have that website redirect the user to your primary domain/site.

Stephen Wrighton
A: 

I have no problem setting up the domains in IIS, will this work if the domains all point to the same IP address? If I go to www.example.com (192.168.1.1) will it ever end up at www.examples.com (192.168.1.1) which redirects to www.example.com and cause an infinate loop because they are on the same IP address?

Wili
When you create a 'web site' in IIS, you can narrow it by the ip AND the header (i.e. go to web site B if it's this ip and the request is for examples.com or www.examples.com)
John
A: 

For the CNAME approach you need to pick ONE domain name and make that your primary. So make www.example.com the go-to, and every OTHER domain name redirects to this one. Then you can avoid the infinite loop.

There is also a way to setup a configuration on the server so that browsers will allow multiple domains to look at a single cookie, in this case, www.example.com, then when www.examples.com and www.ex-ample.com try to read www.example.com's recaptha session info, it will work. This would allow you to still have multiple url's in the browser, and support shared sessions.

Personally I would just redirect them all to a single domain, MUCH easier to implement.

so do:

127.0.0.1        A       example.com
www.exmaple.com  CNAME   example.com
examples.com     CNAME   example.com
www.examples.com CNAME   example.com

etc.

EDIT: Yes, I was asleep when I wrote this. This is only part of the solution, I posted the remainder of it below.

Adam
cnames are not redirecting anything, and how is this actually answering the question?
hop
@hop - CNAMES can be used as a redirect at the DNS level--which means it works better and you're not stuck doing something like Response.Redirect in ASP.NET or worse a META REDIRECT tag. What this is saying is that all those domain names listed send the user to example.com.
Stephen Wrighton
Wow, I must have not slept the day I answered this one. Hop is right, this doesn't solve the problem at the IIS level of getting all URL's to read as 'example.com'.
Adam
A: 

How would CNAME be done in a Windows 2003 DNS Server?

Wili
CNAMES are not too much different to what you already have with the same IP address on all domains. At least not from a user's point of view. That won't help at all.
BlaM
A: 

Ok, on top of my CNAME solution, you would have to do the following:

An IIS solution would be to setup 2 sites in the IIS Manager:

  1. example.com (set in host header)which is the actual site pointing to the proper home directory.
  2. all other domains will be setup under one 'web site' with their host headers added in Properties->Web Site->Advanced. For the home directory, make it a redirection URL to example.com.

The problem with this approach is I believe a request going to www.examples.com/somepage.htm will get forwarded to example.com/. (Will not point to example.com/somepage.htm)

Now what you could do in IIS7 (or IIS6 with Isapi_Rewrite addon) is setup an .htaccess entry on the redirection web site to send all traffic to the example.com and append the path and query string information.

Adam
A: 

Yes, you can accomplish this via the Rewrite Module.

Here is an example:

<rule name="WWW Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
 <add input="{HTTP_HOST}" pattern="^examples.com$" />
</conditions>
<action type="Redirect" url="http://www.example.com/{R:0}" redirectType="Permanent" /></rule>
alex