So how exactly does Stack Overflow (along with other internet sites) take away the 'www' prefix when it is joined included in a URL?
Could it be a redirect, a rewrite or something like that else entirely?
Update: I'd particularly prefer to know poor IIS 6
Firing up Fiddler, we are able to observe that the server reactions having a "301 Moved Permanently" status and refers it to http://stackoverflow.com . Since StackOverflow is located on Home windows 2k8 IIS7 they setup this redirect immediately in IIS7.
If you're a .Internet developer you may know "Respose.Redirect" , this produces a 302 Object Moved status. Search engines like google like 301 status codes within this situation better, simply because they know they ought to not return to world wide web.stackoverflow.com later on.
A good way to get this done is applying the Apache "Redirect" directive:
<VirtualHost *:80> ServerName world wide web.example.com Redirect permanent / http://example.com/ </VirtualHost> <VirtualHost *:80> ServerName example.com # all server configuration goes here </VirtualHost>
The Redirect directive instantly preserves anything following a
/ within the URL. I've found this process simpler to see and understand compared to Rewrite method.
On Apache, it appears such as this (in a .htaccess file):
RewriteEngine On RewriteCond % ^world wide web.example.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
redirect. the sub-domain "world wide web.stackoverflow.com" would simply redirect to "stackoverflow.com".
It can be done a number of ways, using mod_rewrite and redirecting is my personal favorite. Something similar to this:
RewriteEngine On RewriteCond % ^world wide web.mauriciocuenca.com$ [NC] RewriteRule ^(.*)$ http://mauriciocuenca.com/$1 [R=301,L]
You'll need a default dns entry added pointing for your web server.
ping site.com and verify ip is pointing to webserver, otherwise you need the default DNS entry added.
for any fundamental setup:
You will need to add host headers http://world wide web.visualwin.com/host-header/
Create 1 site having a hostheader of world wide web.site.com
In your home Directory tab, place it to some permanent redirect to http://site.com
Produce a second site having a host header of site.com
If you would like world wide web.site.com/file.html to redirect to site.com/file.html you may need a more complex setup with something similar to ISAPI_Rewrite or use custom 404 pages to get it done.
This really is going a lengthy long ago, but so far as I understand this can be a DNS setup. I believe you don't have to specify a number address (World wide web may be the title from the host (or computer/cluster...) the site resides on/in.).
I believe after that you can arrange it to transmit all demands to some default host.
Not 100% sure, but take a look at what's possible with DNS.
Hope that can help or at best get's you pointed in the right direction.
That you can do what mod_rewrite does for Apache, having a comparable URL rewriter for IIS. A high quality one is IIRF. The rule is:
RewriteCond % ^www.example.com$ [I] RedirectRule ^(.*)$ http://example.com/$1 [R=301]
You may also wildcard the hostname like so:
RewriteCond % ^(.+).example.com$ [I] RedirectRule ^(.*)$ http://example.com/$1 [R=301]
IIRF is free of charge.