Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've found some similar answers to this question but was hoping someone could clarify in case I'm misunderstanding. This is hosted on IIS 7 in ASP.NET

On my site, I have root and www domains going to my homepage:

  • example.com goes to my homepage
  • www.example.com goes to my homepage

I also have a URL redirect set up for my users:

  • user1.example.com rewrites to example.com/Page.aspx?u=user1
  • user2.example.com rewrites to example.com/Page.aspx?u=user2
  • etc.

These are all working perfectly, but I'd like to allow my users to register their own domains names to point to their own sites. They would be in control of these names and I would provide a tutorial on how to set them up. I'm pretty sure I can figure out how to get CNAME to work for the www subdomain, but I'd like to get the root URL to work also. Is this possible?

I would like:

  • userdomain1.com to point to user1.example.com
  • www.userdomain1.com to point to user1.example.com
  • userdomain2.com to point to user2.example.com

I could use domain masking but would rather not, as I'd like the domains to perform like actual domain names.

Can this be done, in any way, via DNS and/or coding? Thanks! :)

share|improve this question
add comment

2 Answers

If I understand you correctly, you can't use a CNAME record the way you're asking to. To accomplish what you're trying to do, you'd have to put in A records pointing to some web server(s) that will do http redirects for you. Godaddy can redirect a domain like this for you. They call this "forwarding without masking" in their documentation here:

http://help.godaddy.com/article/422

share|improve this answer
    
Thanks Jake. Is it possible if the A record points to my site, to rewrite on the fly? In other words, if the user points their A record to my site's IP address, then might it be possible to then use IIS 7 URL rewrites to capture their TLD and redirect based on that? (the user would specify their TLD in my database for the lookup). I'll do some looking on this too, but I have a hunch this might be possible. –  trnelson Aug 20 '11 at 15:21
    
In case you're curious, I actually figured out a way to do this (much to my surprise). Posted an answer below. Thanks for your input! :) –  trnelson Aug 21 '11 at 4:49
add comment
up vote 1 down vote accepted

Leaving an answer here for anyone interested, since it seems like I got this working!

For the user's domain name, I will instruct them to point the A record to my website's IP address. I did this via the @ host but I imagine it could be done with the * wildcard host as well.

Then, in my Web.config file I created this entry for the IIS 7 Rewrite Module:

<rule name="UserDomain" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTP_HOST}" negate="true" pattern="^(?:www\.)?example\.com$" />
    </conditions> 
    <action type="Redirect" url="http://www.example.com/Page.aspx?d={HTTP_HOST}" />
</rule>

Basically, this negative regex rule says that any domain that points to this host, which isn't the main website domain example.com, redirect to Page.aspx and pass the domain name in the querystring. This will allow me to lookup in the database just as I need to. The best part about this is that it's not domain masking, and it's not domain forwarding. It's good, clean, DNS goodness with a bit of magic to make it work.

Still need to tweak a bit, but so glad I figured this out! :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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