internet.com

Go to WebDeveloper Home


hm-v6-139x61.gif

Database Journal: The Knowledge Center for Database Professionals

find a web host with:
CGI Access
DB Support
NT Servers
UNIX Servers
Telnet Access

advanced search
jobs

Get FREE Development Info via your Email!

The Webdeveloper channel
FlashKit
GIF.com
HiermenusCentral
webdeveloper Jobs
Java Boutique
JavaScript.com
JavaScript Source
ScriptSearch
StreamingMedia World
WDJ
WDVL
WebDeveloper.com
WebReference.com
XMLFiles.com

internet.com
Internet News
Internet Investing
Internet Technology
Windows Internet Tech.
Linux/Open Source
Web Developer
ECommerce/Marketing
ISP Resources
ASP Resources
Wireless Internet
Downloads
Internet Resources
Internet Lists
International
EarthWeb
Career Resources

Search internet.com
Advertise
Corporate Info
Newsletters
E-mail Offers

internet.commerce
Be a Commerce Partner
Computer Deals
Prepaid Phone Card
Phone Cards
Best Price
Home Improvement
Baby Photo Contest
Server Racks



S I T E
M A N A G E M E N T
WebDeveloper.com

Fix Your WWW!

By David Fiedler

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:

<VirtualHost 1.23.456.789>
ServerName yourdomain.com
ServerAlias www.yourdomain.com

(other lines may appear in here)

</VirtualHost>

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:


<VirtualHost 1.23.456.789>
ServerName www.yourdomain.com
ServerAlias yourdomain.com *.yourdomain.com

(other lines may appear in here)

</VirtualHost>

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:

<VirtualHost www.yourdomain.com yourdomain.com>
ServerName www.yourdomain.com

(other lines may appear in here)

</VirtualHost>  

And that's all there is to it!

This article first appeared in October, 1999.

Fast Jump to Anywhere on WebDeveloper.com®:


Contact the WebDeveloper.com® staff

Last modified: 20

 

Refresh Daily
Join Editor-in-Chief David Fiedler The Editor With No Time and find truth, justice, and a clue or two.


Browse by Category
[ Site Map ]

ActiveX / VBscript
Animated GIF Archive
Browsers
CGI / Perl
Database Connectivity
Design / Graphics
E-Commerce
HTML-Advanced: DHTML, CSS
HTML / Site Authoring Tools
Intranet/Groupware
Java
JavaScript
Multimedia: Audio / Video / Streaming Technologies
Opinions
Refresh Daily: Editorial Column
Security
Servers & Server Tools
Site Design / Graphics
Site Management / Marketing / Log File Analysis
Tutorials
VRML / 3D
XML




JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers