Technology in terms you understand. Sign up for the Confident Computing newsletter for weekly solutions to make your life easier. Click here and get The Ask Leo! Guide to Staying Safe on the Internet — FREE Edition as my thank you for subscribing!

How do I direct my web traffic to a single domain?

I own several domains – mostly variations and misspellings on my “real”
domain, and of course have the domains both with, and without, “www”. I’ve been
told it’s a good idea to have them all end up in a single place. I know how to
make them all show the same content, but I’m told that’s not enough. What is,
and how do I do it?

OK, this one’s geeky, and is obviously aimed
at webmasters who are managing their sites. But it’s another question I actually
get on a regular basis from folks who’ve visited my site.

Yes, it’s easy to get “example.com” and “www.example.com” to show the same
content, and essentially “be” the same site. But if you’re looking to maximize
your search engine placement, and present a single, unified site – that may not
be enough.

Become a Patron of Ask Leo! and go ad-free!

Ask Leo! is a great example of what I mean. I actually own several domains
that I want to refer to this site:

  • ask-leo.com is the domain
    I’ve chosen to standardize on. This is “the” domain for Ask Leo!

  • ask-leo.net same idea,
    different top-level domain (TLD), in case people mistype

  • ask-leo.info same idea,
    different TLD, in case people mistype

  • askleo.info is a domain I
    use when I’m speaking – I call it my “aural URL” because it’s much easier to
    get right when you hear it.

And all of those work both with, and without, a “www.” in front of them.

(You may ask why I don’t have “askleo.com” – it’s owned by a domain squatter
who, last time I checked, wanted too much money.)

If you click on any of those, though, you’ll be taken to my “primary”
domain, ask-leo.com – when the page finally loads, that’s the address you’ll
see in the address bar.

The same is true for “www.” – I’ve chosen to standardize on not
having the “www.” in my URLs, so if you do go to www.ask-leo.com, you’ll still end
up on my primary domain, “ask-leo.com”, without the “www”.

So a quick test for your site: if you go to “www.example.com”, and just
“example.com”, are the resulting URL’s identical? (Replace
“example.com” with your domain, of course.) Have you picked whether you want to
standardize on with, or without “www” and then used redirection to enforce it?
If not, you’re probably loosing some search engine ranking. Some search engines
may see them as two separate sites – “www.example.com” and
“example.com”.

The typically accepted practice to make this happen is redirection. If a
request comes in to your web server for one of your non-standard domains, the
server redirects it, using what’s called a 301 permanent redirect response
code.

I do it using the URL Rewriting feature of the Apache web server.

Ideally in the server configuration file (httpd.conf, or a related file), or
alternately in the “.htaccess” file, if your server configuration allows it,
you can include the instructions to “rewrite” the URL that is about to be
processed. We’ll rewrite it to be a redirection to the desired URL.

Here are the rewriting instructions I use for ask-leo.com:

RewriteEngine on
RewriteCond %{HTTP_HOST}   !^ask-leo\.com [NC]
RewriteRule ^/(.*)         http://ask-leo.com/$1 [L,R=permanent]

RewriteEngine on simply ensures that rewriting is
enabled.

RewriteCond defines a condition that, only if met
will cause the next statement to be executed. My condition is that the
“HTTP_HOST”, or the domain portion of the request does
not (!) match exactly “ask-leo.com”. (NC indicates a
case-insensitive comparison).

RewriteRule defines the rewrite to happen: the entire
requested url after the host name, is replaced with my preferred domain,
followed by that original URL.

In English, the bottom line is that the rule is simply this: “if we get a
request for a URL that isn’t on ask-leo.com, make that same request on
ask-leo.com instead.”

That’s all there is to it. I know that if you’re not familiar with the
rewriting syntax it looks daunting, but it’s conceptually very simple.

Note also that the way this rule is defined, any URL gets
redirected, not just the site root. For example if you try to go to http://www.ask-leo.com/how_do_i_keep_my_computer_safe_on_the_internet.html,
you will end up at the correct page, but the URL will have been rewritten to
remove the “www.” because that’s what I’ve standardized on.

Subscribe to Confident Computing! Tech problem solving & safety tips with a weekly confidence boost in your inbox every week.

I'll see you there!

10 Reasons Your Computer is Slow

Slow Computer?

Speed up with my FREE special report: 10 Reasons Your Computer is Slow, now updated for Windows 10.

No strings. No email. Here's the direct download. (Just right-click and "Save As...".)

1 thought on “How do I direct my web traffic to a single domain?”

  1. i have one website i.e http://www.impactmarketingservice.com hosted on Network solutions,now i want to redirect all the 11 domains that i had registered from rediff.com,to this site(www.impactmarketingservice.com)

    for tht,sd i need to host all the 11 domains????and how redirection will take place to the current site..plz send the feedback…

    Reply

Leave a reply:

Before commenting please:

  • Read the article.
  • Comment on the article.
  • No personal information.
  • No spam.

Comments violating those rules will be removed. Comments that don't add value will be removed, including off-topic or content-free comments, or comments that look even a little bit like spam. All comments containing links and certain keywords will be moderated before publication.

I want comments to be valuable for everyone, including those who come later and take the time to read.