|
|
Fix Your WWW!Do you advertise your domain.com address but your Web site doesn't work unless you specify www.domain.com? Here's how to fix it in Apache.Duh. That's what I say when I go to a Web site -- especially one where the company behind it has spent a lot of money advertising its shiny new domain.com address -- and it doesn't work. Not because the site is down, but because typing the actual address being advertised (domain.com as an example, though that one doesn't work at all so don't bother trying it) won't work unless you type "www.domain.com" into your browser. Well, double duh. Do they expect the average person on the street to know you're supposed to type in "www." in front of a Web site address? After all, browser designers quickly learned that forcing people to type "http://" was too great a strain for users' minds. Besides, spending millions of dollars to make people familiar with your address, and then having that address not work, is about as stupid as advertising your telephone number on nationwide TV without giving the area code. Try it with some well-known domains, and you will be amazed at how prevalent this problem is. Of course, if you're still reading this, it's probably because you've just frantically typed your own domain name into your browser and found out the bad news...or worse, you're the Webmaster at your company, and the company president just read this article and called you with the bad news! Luckily, it's simple to fix.
Assuming for a moment that you're running Apache (which is a pretty good assumption with around 60% of the market), there are several ways you can accomplish this fix, all of them involving entries in your httpd.conf file. If you're using Apache 1.1 or later, you can use the ServerAlias directive, which would end up looking something like this:
You can also write those lines like this, which would have the effect of having any prefix, not just www, directed to your Web server's home page:
Instead of using ServerAlias, you could add the www-challenged name to the VirtualHost directive, although it's important to make sure that the first name in that directive is the same as the ServerName, as done here:
And that's all there is to it! This article first appeared in October, 1999.
Contact the WebDeveloper.com® staff Last modified: 20
|
Refresh Daily
|
| Solutions | ||||||
|
||||||
|
||||||
|
||||||
|
||||||