[web] regarding domain names and www

Started by
10 comments, last by rjunique 18 years, 1 month ago
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.
Advertisement
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.
Quote:Original post by alnite
This 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.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

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.
Quote:Original post by benryves
Also, 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
Quote:Original post by Colin Jeanne
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.

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.
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

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

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 :)

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

Quote:Original post by Sander
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

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.
Quote:Original post by alnite
Quote:Original post by Sander
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

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)

This topic is closed to new replies.

Advertisement