Networking

Redirect domain names

[ This article is an excerpt from Take Control of Your Domain Names , by Glenn Fleishman (2007; reprinted by permission of TidBits Electronic Publishing ). ]

Registering more than one domain name to point to a single Web site isn’t unusual. Nor is it strange to host a Web page at an ISP or community site and want a subdomain to bring people directly to what’s often a long and hard-to-remember URL.

Redirection is the answer. With redirection, browsers can be pointed from a subdomain to a Web site. You use redirection when you want something you don’t control to be pointed to by something you do.

For instance, if you have a community page at a social or group site, and its URL is something extraordinarily bulky, you might prefer a shorter address to act as the public URL.

There are three main ways to create a redirect: With HTML or JavaScript on a Web page, using stealth redirection, or directly via DNS settings. (Note that if you run your own Web server or have access to the configuration settings on your Web host, you can also implement redirection using the Web-server software.)

How DNS resolution works

Domain Name System (DNS) is the glue that binds subdomains and IP addresses. Here’s how it works.

  • Your browser queries your computer’s DNS resolver for europe.socko.com’s IP address.
  • The resolver queries your ISP’s DNS server.
  • The ISP’s DNS server starts at the top of the domain hierarchy, querying, in turn, the root nameserver (represented in DNS as just
    .
    [a period]), the .com’s nameserver, and socko.com’s main nameserver. Because Socko Corp. delegates authority for its divisions worldwide, your ISP’s DNS server is told to check dns-eu.socko.com for European DNS information.
  • Your ISP’s DNS server checks dns-eu.socko.com and receives back the IP address for europe.socko.com.
  • The ISP’s server hands back the IP address to your DNS resolver.
  • Your DNS resolver hands that address to your browser.
  • Finally, your browser connects to the European Socko Web server by its IP address to retrieve the content.
  • Web-page redirects

    To set up a redirect, you can use a special feature in HTML or a command in JavaScript. Such redirects can take a little longer, must be applied on every affected Web page, and require the browser’s involvement. Despite these disadvantages, the redirection is entirely within your control and doesn’t require special Web-server software configuration that your Web-hosting firm may not provide.

    HTML Tags The

    meta
    tag provides information about a page and can define attributes that control browser behavior. The attributes we’re interested in are
    http-equiv
    , which tells most browsers to reload the page using the URL that’s specified next, and
    content
    , which provides the parameters. The parameters are the time to refresh (measured in seconds) and a URL. The tag might look like this:

    <meta http-equiv="refresh" content="0;url=http://glennf.com/new_page.html">

    The

    meta
    tags must be in the
    head
    portion of the HTML for a Web page. For redirection, I suggest creating the shortest possible page to make reloads as fast as possible, as shown here:

    <html>   <head>   <title>Redirecting</title>   <meta http-equiv="refresh"   content="0;url=http://glennf   .com/new_page.html">   </head>   <body></body> </html>

    (Of course, you’ll use your own URL, not mine.)

    JavaScript A simple script, such as the one that follows this paragraph, works more efficiently than the

    meta
    tag, because the script redirects to the new URL as soon as the browser receives it. However, some users may disable JavaScript, rendering the script useless for them. For best results, pair the script with the
    meta
    tag redirect. Put the JavaScript in the
    head
    portion of the page; follow it with the
    meta
    tag.

    <script type="text/javascript"> <!-- window.location = "http://www.glennf.com/" //--> </script>

    Stealth redirection

    Stealth redirection uses Web frames to make the browser display both the originating URL and the destination Web page. Most modern browsers support frames. But note that stealth redirection can negatively affect the way search engines index your site, and some tools to fight fraud might flag your site as problematic.

    Most DNS hosts offer some form of stealth redirection in addition to regular redirection. Here’s how you’d turn on either form of redirection at one DNS host, easyDNS; the steps are similar at many others.

    First, log in to your account. Find the domain name for which you want to add stealth redirection, and click on the DNS link to the right of its name. Scroll down to URL Forwarders. (If the contents aren’t displayed, click on the plus sign [+] on the right side of the box.) Enter the subdomain you want to forward and the URL to which it should forward. Select the Stealth option to use stealth redirection; leave it deselected for normal redirection. Click on Next to confirm and activate the changes.

    Multiple subdomains

    Using multiple subdomains at one domain name allows you to have many addresses that resolve to the same Web site. For instance, when users type in

    	www.fresh-eggs.com
    	
    or
    	www.cage -free-chickens.com
    	
    , you might want them to land at the same place.

    To point multiple subdomains to one set of files, contact your Web host and inform it of the subdomain names you want to point to a Web site. Some Web hosts may let you enter this information directly via your account. Obtain the IP address settings from your Web host for where to point the subdomains. Visit your DNS host and enter the subdomains you’re defining and the associated IP addresses (or just the IP addresses if you’re moving the pointer for existing subdomains).

    [ Glenn Fleishman writes about Wi-Fi and Macs from his home in Seattle, Washington. ]

    Subscribe to the Apple @ Work Newsletter

    Comments