Web Hosting Talk







View Full Version : http:// and http://www.


misterdanny
04-12-2006, 05:33 PM
what is the true difference between having the www. and not having the www. they are treated as seperate domain names but their not.
also how can i make it so if the user doesnt type in www. it automaticaly goes to the domain with www. in it

BrookeM
04-12-2006, 05:42 PM
what is the true difference between having the www. and not having the www. they are treated as seperate domain names but their not.
also how can i make it so if the user doesnt type in www. it automaticaly goes to the domain with www. in it

The "how" is relatively easy, but varies. Are you hosting your own nameservers, do you have a hosting company that lets you make changes to your own records or do you not have access to your own A record, MX record, etc.? I'm assuming your hosting company manages your nameservers. If that is the case, and they allow you access to make changes to your own records then they likely have some kind of control panel that may have check box with something like "add www." (although most make it so someone typing the domain with or without the www. would still be directed to the same site when you put in your A record in the first place), but if you're not sure where to access that panel, or they don't allow you to make those changes yourself I'd suggest contacting their support department to have that change made to the nameservers for you. If you're using a 3rd party DNS service the same advice would apply.

misterdanny
04-12-2006, 06:00 PM
actualy my first, or what i thought was a solution was to make some sort of htaccess file to redirect. would it still be better to get the admin of my nameserver to do it?

is this thing your talking abuot essentially the same as making an htaccess file?

Stan Marsh
04-12-2006, 06:23 PM
misterdanny, as BrookeM already pointed out, this is DNS issue. htaccess wouldn't help.

In order to solve this, you need at least some control over your nameservers, specifically A and/or CNAME records. Do you have it? Depending on your answer, we'll try to find a way to help you.

stub
04-12-2006, 06:45 PM
.htaccess can handle it, no problem. I've got this in my .htaccess file

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

Stan Marsh
04-12-2006, 06:51 PM
.htaccess can handle it, no problem. I've got this in my .htaccess file

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

This will tell Apache (mod_rewrite) to modify url, displayed at the browser window. Nothing more. It will NOT solve the problem.

Infact, as far as I understand it will CREATE huge problems, if mod_rewrite isn't installed in that particular server.

My 0.0002 worth.

stub
04-13-2006, 12:29 PM
I'm not an expert in .htaccess files, Stan. So I'd bow to your superior knowledge. I got this info from over at WMW, in their Apache forum. It works for me. If I type in http://example.com it resolves to http://www.example.com. It's used to do a 301 redirect from the non-www to the www domain so that the search engines (google primarily) don't split your domain in 2, as they treat www.example.com and example.com as 2 separate domains. As such, it answers misterdanny's question exactly.