These forums are read-only!
subdomains pointing at URL's
  • Is it possible to setup subdomain redirects that go to other URL's (rather than IP's) through the DNS management panels? I like to create handy subdomains on my sites to redirect to Google apps for the site, for instance. I'd also like to create redirect subdomains to hit a depth of the same site (e.g. blog.site.com, badmin.site.com). It'd be easiest to redirect those to a URL.

    I've tried setting it up, but it doesn't seem to be working at this point.

    TIA,

    Barry
  • DNS doesn't support this directly; point it to your slice, then add a virtual host for the domain in question. In it, use mod_rewrite to send accesses wherever you want.
  • I actually ended up doing:

    <VirtualHost *:80>
      ServerName gmail.site.com
    
      Redirect permanent / http://site2.com/
    </VirtualHost>
    

    Anything wrong with that technique? My plan is to have a /usr/local/apache2/conf/redirects/ directory that will be included into my base httpd.conf file.

  • bdonlan is incorrect. DNS does allow this it's called cname. You can go anywhere you wish. Also if you are using google apps they provide you with the information to setup the CNAME records so that your site will redirect mail.mysite.com to your own google login site.

    For instance I currently have google handling the mail for my domain. And on my DNS records for slicehost I have a CNAME of mail redirecting to ghs.google.com. Of course you also have to setup MX records for your site to utilize actually mailing to your site.
  • He's not incorrect - a CNAME simply causes your domain to resolve to the same IP as another domain - not a URL. URLs are at a different layer of the network stack. In the case of something like google apps, a CNAME is fine, as they explicitly support you pointing your domain at them. In other cases, your only option is a 'cloaking' style service, which works with HTTP server redirects.
  • Disagreements aside, is my method kosher?

  • Absolutely. As dirtymafia points out, though, if you're using google apps, they do support CNAMEing your domain to them, which is somewhat neater and easier.
  • Thanks for all the advice, everyone. I think I'll avoid the CNAME thing, believing that a single redirect strategy will minimize my maintenance issues going forward.

  • all a domain name is is a pointer to an ip address, period. So saying that DNS doesn't support redirecting to a url is wrong, because it does (CNAME). If someone has a domain name it can be cname'd you do explicitly allow it. The only thing you are doing is redirecting the request to request from the top down again. So lets say I request mail.mydomain.com and the record in DNS for mail is a cname to mygooglemail.google.com I would then request from the root servers (by means of my local dns servers) again for the mygooglemail.google.com. There is NO way to actually point to a url because a url does not exist (really) it just points to another ip address.

    And bjhess I would recommend using the CNAME as it has less of a chance to cause problems, and less down time. If your apache goes down so does your redirect. Not to mention it is an extra hop for the browser, which of course doesn't take that long. However your dns is backed up on 3 slicehost dns servers which gives you more redundancy. Also you probably shouldn't make your redirect permanent if you do stay with your apache redirect.
  • DNS does not handle http redirects. CNAME records will not handle http redirects.

    If you simply use a cname, then the "host" field in the http request header will be incorrect, even though you may be pointing to the correct ip address... bjhess has the right idea.

    @ bjhess Yes. Your solution will work fine. You might consider a rewrite directive instead though..so any garbage off the end of the url can be removed..but it likely isn't needed for simple 'ease of use' redirects.

  • I stand corrected.