Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

To be clear: I am not asking whether or not I should use www in my url, or what the pros and cons are, that topic is well covered. I also wasn't sure if this was a Stack Overflow, Server Fault, or Webmaster's question - migration to a more appropriate channel is quite welcome.


Background: I was recently asked to convert a site's urls to all use www, as in http://example.com to http://www.example.com. The reason for the request is over my head. I present an excerpt from the email:

Got an issue,

Apparently whenever the site was originally setup with their network (prior to me), the installers chose to use the internal domain as 'example.com' ... not good ...

This is a problem trying to resolve externally .... I looked at a few qweb page source coding and saw many links are coded as 'http:\example.com\PAGE.XXX' ...

Can it possibly globally be changed from 'http:\example.com' to 'http:\www.example.com'

I can resolve www, but once I hit a link it thinks the server is the internal EXAMPLE which houses the domain 'example.com' ...

Something to do with the client not being able to access the website on their own network. As I mentioned, I don't quite understand it.

So, I implemented the change, but while testing, I accidentally typed in an extra w, and to my surprise - the site still worked.

Then I tried several w's, then two, then I typed in some nonsense and the site still worked.

EDIT: To be more accurate, only alpha, numeric, dash, and underscore characters will resolve, anything else returns a Server not found error in the browser.

I just tested this on Stack Overflow and got redirected when I used www, while everything else returned a "Server not found" error.

Does anyone have any insight into what the point of this email request is, and why the accidents and experiments I mentioned worked?

I can certainly provide more information, I'm just not sure what would be relevant.

share|improve this question

migrated from stackoverflow.com May 26 '11 at 22:12

This question came from our site for professional and enthusiast programmers.

    
Never heard of that before... almost like a "catch-all" for sub-domains where you can literally type anything and still get to the main domain. So what happens when you try test.yourDomain.com? Does it rewrite or redirect to www. or does the test. persist in the URL? –  Sparky May 25 '11 at 5:28
    
Look in the W3C site. –  Anonymous May 25 '11 at 5:31
    
@Sparky672: It displays normally, no redirect or anything. –  Wesley Murch May 25 '11 at 5:33
    
@Wesley: Just to reiterate... you can include any gibberish sub-domain imaginable and it just works? Weird. A "Mod Rewrite with wildcards" was my initial thought but if the random sub-domain persists in the URL, I have no idea of the mechanism behind it. –  Sparky May 25 '11 at 5:41
2  
It's a DNS wildcard but it's still subject to DNS naming standards which doesn't allow just any character data. –  Anonymous May 25 '11 at 5:48
show 2 more comments

3 Answers 3

up vote 9 down vote accepted

www is a subdomain of example.com.

You can configure DNS to have multiple sub domains which resolve to different web servers and hence give you a different site.

example.com (no subdomain)

site2.example.com

site3.example.com

It sounds like whoever set up the network, set example.com to resolve to the internal web server, on the networks DNS server, this is accessible only to hosts on the internal network. So anyone who browses to example.com inside the network see's a different website to those externally, as they use a different DNS server to resolve example.com. It may have been better to give this its own sub domain. e.g internal.example.com

A user inside the network browses to www.example.com hits a link and is taken to example.com which is fine externally, but internally they resolve to different web servers, which is why you have been asked to change the links.

If the content on the internal server is the same as the external, then you could end up with the reverse problem. When browsing the internal site, any hyperlink takes you to the external site.

If possible you might find it better to use relative URLs in your hyperlinks. e.g.

Instead of <a href="http://example.com/index.htm">Index Page</a>

You would use <a href="/index.htm">Index Page</a>

The browser would then choose http://www.example.com or http://example.com depending on the site that you browsed to.

Why the wwww works could possibly be Wildcard DNS entry, which means *.example.com resolves to the same IP, effectively a catch all for sub domains that don't exist.

share|improve this answer
    
Nice explanation, it's becoming clearer to me now. Good tip about the relative URLs - I'm using them for 90% of the site already, but sometimes they slip under the radar since we're using a CMS for everything. So, technically, one could opt not to allow www to resolve as a subdomain? –  Wesley Murch May 25 '11 at 6:25
    
Yes, although it is commonly done. With full DNS control I believe you have to explicily set the DNS entry for the www. My DNS provider automatically adds www as a subdomain. –  Anonymous May 25 '11 at 7:09
add comment

WWW is an acornmyn for the World Wide Web, it also happens to be a common subdomain employed by people to designate that the domain is hosting a web site.

The use of a subdomain name is useful for load balancing incoming web traffic by creating a CNAME record that points to a cluster of web servers. Since, currently, only a subdomain can be cname'ed the same result cannot be achieved by using the bare domain root.

In most cases I believe the www. subdomain is omitted and it doesn't really matter if you type the one or the other. However, given what the web looks like today and seeing as how HTTP and the web is really ubiquitous, I would never mandate the inclusion of www. in the domain name and if you look a web sites today you'll notice that sites such as facebook and google prepend www., even if you don't type it.

Why it works even when you type other things has to do the way your DNS is setup for that domain. There are ways to handle wildcards and forward all traffic regardsless of subdomain to the same web server. But it's up to the web server to respond to each individual host header in some manner and this is entierly configurable (and obviously you need to check what the configuration is to answer the question in full).

share|improve this answer
    
So what explains how the OP can literally type any sub-domain into the URL and it still works? –  Sparky May 25 '11 at 5:37
    
Given that the web servier is setup in a similar fashion. The web server has to map wildcards as well to the right web site. That is, what ends up in the host header could probably be anything but if it isn't mapped correctly it won't land in the right web site. –  Anonymous May 25 '11 at 5:39
    
It's not making sense to me. He claims that he can literally type any gibberish into the sub-domain and the site still comes up fine with that random sub-domain included in the URL. –  Sparky May 25 '11 at 5:44
2  
Yes, DNS wildcards (I even linked it in the answer), I'm telling you. You can have wildcard subdomains and if your web server does host mapping using wildcards as well that will work. Just as described. –  Anonymous May 25 '11 at 5:46
    
I'm not disputing your explanation. Just making sure we're all on the same page as the OP while also stating that his description is a new one to me. –  Sparky May 25 '11 at 5:50
show 1 more comment

If they are trying to use exactly this "url": http:\example.com\PAGE.XXX then nothing will help them.

As of www suffixes in www.example.com ...

Historically 'www' as 'ftp', 'pop3', etc. were names of machines running corresponding services inside 'example.com' domain. And actually this schema is still used in many companies.

share|improve this answer
add comment

Your Answer

 
discard

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.