# [web] regarding domain names and www

This topic is 4512 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I just registered a domain, and I have a little question regarding the domain name and www host name. Using gamedev.net as an example, when you type in gamedev.net, the address bar automatically converts it to www.gamedev.net, however this is not the case with my domain. I typed in my domain and it stays the same and doesn't add "www". Why is this? This is trivial since they both would access the same content, but I'd just want to know.

##### Share on other sites
You need to provide an automatic redirect in order to do this. How to do it depends on your server software. Gamedev uses IIS and so I am unsure how they do it but with Apache you can use a .htaccess file and create a simple redirect.

##### Share on other sites
Quote:
 Original post by alniteThis is trivial since they both would access the same content, but I'd just want to know.
Bear in mind that some things do not carry over. For example; an AJAX application that tries to access a file on http://www.mysite.com/ will not let you do so if you are looking at the site from http://mysite.com. Also, I do not believe that sessions or cookies carry over between the two domains.

##### Share on other sites
When Opera doesn't find a site on the address you typed, it tries again prefixing www. to the adress.
But yeah, normally it's a server setting.

##### Share on other sites
Quote:
 Original post by benryvesAlso, I do not believe that sessions or cookies carry over between the two domains.

This is true and is the reason all forms of my domain redirect to the www version

##### Share on other sites
Quote:
 Original post by Colin JeanneGamedev uses IIS and so I am unsure how they do it but with Apache you can use a .htaccess file and create a simple redirect.

Do you know what the command is? I tried quite a bunch; some of them caused infinite loop, and none of them seem to work.

##### Share on other sites
Try:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain\.name [NC]
RewriteCond %{HTTP_HOST} !^$RewriteRule ^/(.*) http://www.domain.name/$1 [L,R]

from: http://httpd.apache.org/docs/1.3/misc/rewriteguide.html

##### Share on other sites
OT: I found a site (forgot the domain name already) yesterday that didn't allow you to access it unless you typed the www. part. Wow, welcome to 1995, I swear I had a flashback. I've not actually typed the www part in over 6 years at this point. I figure if they cannot even get this part right, the rest of the site is likely poorly designed (by a someone lacking knowledge on the ways of the internet) and I won't likely need it :)

##### Share on other sites
Quote:
 Original post by SanderTry:RewriteEngine onRewriteCond %{HTTP_HOST} !^www\.domain\.name [NC]RewriteCond %{HTTP_HOST} !^$RewriteRule ^/(.*) http://www.domain.name/$1 [L,R]from: http://httpd.apache.org/docs/1.3/misc/rewriteguide.html

You know what, I tried that, but it didn't work [cry]. I tried putting it in the .htaccess on the /www directory, not working. On the / directory, also not working. Both, also not working. I am very thoroughly confused now. The server reads the .htaccess file (I tried putting garbage in and it spits out a server error), but for some reason that code doesn't seem to have any effect.

##### Share on other sites
Quote:
Original post by alnite
Quote:
 Original post by SanderTry:RewriteEngine onRewriteCond %{HTTP_HOST} !^www\.domain\.name [NC]RewriteCond %{HTTP_HOST} !^$RewriteRule ^/(.*) http://www.domain.name/$1 [L,R]from: http://httpd.apache.org/docs/1.3/misc/rewriteguide.html

You know what, I tried that, but it didn't work [cry]. I tried putting it in the .htaccess on the /www directory, not working. On the / directory, also not working. Both, also not working. I am very thoroughly confused now. The server reads the .htaccess file (I tried putting garbage in and it spits out a server error), but for some reason that code doesn't seem to have any effect.

The server could be set to only read certain things from .htaccess files. One reason to do that would be to allow clients to use .htaccess for authentication but not for anything else.

Server side script redirect might be your only option. (other then switch web hosts)

1. 1
2. 2
frob
16
3. 3
4. 4
Rutin
11
5. 5

• 13
• 13
• 60
• 14
• 15
• ### Forum Statistics

• Total Topics
632124
• Total Posts
3004248

×