mail us  |  mail this page

products  |  company  |  support  |  downloads  |  isp services  |  contact us

ZYTRAX OPEN LOGO

HOWTO support http://example.com

This HOWTO configures a DNS server to allow URL's of the form http://www.example.com and http://example.com - both URL's will get to the same web server. Seems it's the cool thing to do these days. Though just to really tick you off - if you type example.com into a decent browser (read Gecko based) it will automatically try www.example.com for you! So you don't actually need to do anything - 'cept use a good browser.

Beware: You will also have to change your web server for this to work (change defined below for Apache using Virtual hosts).

; zone file fragment for example.com
....
; SOA NS MX and other stuff

; define an IP that will resolve example.com
                 IN      A      192.168.0.3
; you could also write the above line as 
; example.com.  IN      A      192.168.0.3
www             IN      CNAME  example.com. ; dot essential
; aliases www.example.com to example.com
; OR define another A record for www using same host
; this is the least number of changes and saves a CNAME
www              IN      A      192.168.0.3

The above will also work for any other service, such as ftp, as long as different ports are in use, for example, ftp://example.com will work if your FTP server was appropriately configured and on the same host.

Apache change

Assuming you are using virtual hosts on an Apache server you will have a definition in your httpd.conf file something like this:

<VirtualHost 10.10.0.23>
    ServerAdmin webmaster@example.com
    DocumentRoot /path/to/web/root
    ServerName www.example.com
    ErrorLog logs/error_log
    CustomLog logs/access_log common
</VirtualHost>

you need add a second definition with ServerName modified to reflect your change as follows:

<VirtualHost 10.10.0.23>
    ServerAdmin webmaster@example.com
    DocumentRoot /path/to/web/root
    ServerName example.com
    # if logging per host needs separate files
		ErrorLog logs/another_error.log
    CustomLog logs/another_access.log common
</VirtualHost>

An alternate method is to use a single <VirtualHost> definition using the ServerAlias directive as shown below:

<VirtualHost 10.10.0.23>
    ServerAdmin webmaster@example.com
    DocumentRoot /path/to/web/root
    ServerName www.example.com
    ServerAlias example.com
    # if logging per host - use a single file
		ErrorLog logs/error.log
    CustomLog logs/access.log common
</VirtualHost>

Notes:

  1. In many cases when you type example.com in your browser, the ever helpful browser will auto-complete (or guess) that what you really meant was www.example.com and add the www. So after all that hard work in many browsers example.com would have worked even if you had done nothing!

  2. If you are using MS Frontpage extensions with a single <VirtualHost> definition then the ServerName must be the name that is used to login to FP. In the example above the FrontPage login name used would be www.example.com. When using FP if the ServerName were example.com and the ServerAlias were www.example.com then the FP login would fail.


Problems, comments, suggestions, corrections (including broken links) or something to add? Please take the time from a busy life to 'mail us' (at top of screen), the webmaster (below) or info-support at zytrax. You will have a warm inner glow for the rest of the day.

Pro DNS and BIND by Ron Aitchison

Contents

tech info
guides home
dns articles
intro
contents
1 objectives
big picture
2 concepts
3 reverse map
4 dns types
quickstart
5 install bind
6 samples
reference
7 named.conf
8 dns records
operations
9 howtos
10 tools
11 trouble
programming
12 bind api's
security
13 dns security
bits & bytes
15 messages
resources
notes & tips
registration FAQ
dns resources
dns rfc's
change log

Creative Commons License
This work is licensed under a Creative Commons License.

If you are happy it's OK - but your browser is giving a less than optimal experience on our site. You could, at no charge, upgrade to a W3C STANDARDS COMPLIANT browser such as Mozilla

web zytrax.com



Resources

Systems

FreeBSD
NetBSD
OpenBSD
DragonFlyBSD
Linux

Applications

OpenOffice
Mozilla
SourceForge
GNU-Free SW Foundation

Organisations

Open Source Initiative
Creative Commons

Misc.

Ibiblio - Library
Open Book Project
Open Directory
Wikipedia

printer friendly

Print Page

SPF Record Conformant Domain Logo

Copyright © 1994 - 2009 ZyTrax, Inc.
All rights reserved. Legal and Privacy
site by zytrax
Hosted by super.net.sg
web-master at zytrax
Page modified: January 06 2008.