Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I was told to ask on Server Fault when I asked on Super User, and that makes a lot of sense to me, so here it is.

I like the look of no www but am somewhat worried about drawbacks, such as shared cookies across the root and all subdomains (not that I actually know anything much about cookies at the moment, but I do want to futureproof).

My guess is this might possibly be possible through some sort of alias type thing. But I could be wrong, so here I ask.

So, to clarify, is it possible to have in the address bar while is actually being accessed?

Edit: I'm planning to host with NearlyFreeSpeech.NET. The server is Apache and I would guess the OS is some flavor of Linux.

Edit 2: So do you actually understand what I mean? What I'm looking for is this: when one browses to the site, is what they see in the address bar but is what is being accessed. I have to say Xorlev's answer looks the closest but will it work out, considering potential cookie issues and that I'm going to be using shared IP hosting.

share|improve this question
Are we talking from the perspective of your own website, or all websites in general? – Thomas Oct 5 '09 at 0:36
Yes it is possible - but can you confirm your OS and webserver? – Coops Oct 5 '09 at 19:17
Yeah, one sec. I'll edit the post. – Nathaniel Oct 5 '09 at 19:18
So are any of these answers going to work with shared IP hosting, like NearlyFreeSpeech.NET uses? – Nathaniel Oct 8 '09 at 23:04

8 Answers 8

Yes. Depending on the web server configuration, you either need to not do anything (if using IP-based virtual hosts or not using virtual hosts at all) or configure a name-based virtual host with a ServerName and ServerAlias directive.

In Apache, that would look like:

NameVirtualHost *:80
<VirtualHost *:80>
# Virtual host document root, logging, other configuration here

You will also need DNS for both and to resolve to the same address.

share|improve this answer

I would comment, if I were allowed to.

Charles' answer is correct. One thing you might want to do a little differently. I normaly set the DNS entry as an A record to the IP and the entry as a CNAME record to So In case your IP changes, you don't need to change both. But that's a small detail.

share|improve this answer

I don't think any of these answer it. Your main problem is going to be with cookies: if you set them at, the browser will send them in for *, including domains that serve static content such as or Your problem then is that an interim cache, such as a caching proxy or even a browser, may refuse to cache anything that was requested with cookies. This sends the load back to your primary server.

Many people recommend having a www subdomain so that you can serve your cookies from there and not have them sent back for your static subdomain. Unfortunately, if you do this, you cannot get a no-www URL. My recommendation is to use an entirely different top level domain for static content:


Look at as an example. They don't have a www and they serve images and CSS from

share|improve this answer
Right. Thanks, good answer. – Nathaniel Jul 9 '10 at 3:45
+1 for first relevant answer – zildjohn01 Aug 31 '10 at 19:40

You could rewrite the url if it includes www.

Something along the lines of:

RewriteEngine On
RewriteCond %{HTTP_HOST}   ^www\.NearlyFreeSpeech\.NET [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://NearlyFreeSpeech.NET/$1 [L,R=301]

Not entirely sure that'll work out of the box but should be close.

share|improve this answer

Independent of which domain you choose - keep in mind to be consequent with it. Indexing from search engines are affected by your choice.

i.E. Google:

share|improve this answer
Like above the 301 redirect will help indexing. – Xorlev Oct 5 '09 at 21:51

At the main page of, you can show the site inside an iframe, so while the user goes to and sees, the cookie will come from

share|improve this answer
Hmm, nice thinking. That may possibly wreak havoc with CSS, though. – Nathaniel Oct 10 '09 at 22:16
I don't see how it can break CSS ? – hayalci Oct 11 '09 at 12:32

I don't know about the cookies, but as far as accessing your web site via and is concerned, you need to add a domain A record to your DNS zone that points to the ip address of your web server. You may or may not have to add hostheaders to your web site for this to work, I don't remember and don't have a server handy to check.

share|improve this answer

Yes, it's possible, and I recommend it.

You probably want to add a permanent redirect so that "*" redirects to "". You don't say what web server you use, but it should be easy enough in any one of them.

share|improve this answer
Actually, that's now quite what I wanted to do. I want to have when is being accessed. – Nathaniel Oct 5 '09 at 19:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.