Forum Moderators: phranque

Message Too Old, No Replies

www and not www

confusion over why and how

         

soapystar

8:43 pm on Dec 26, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



im confused over how some sites use the www prefix and some dont..and some use both...ive got sites asking for reciprocals that are index with and without the www prefix...can this be used for cloaking or some other tricks?..and how doo u get the domain to show without the www anyway?

dingman

9:11 pm on Dec 26, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As for how, that's easy. In Apache:

<VirtualHost www.domain.tld>
DocumentRoot /path/to/site/files
ServerAdmin user@domain.tld
ServerName www.domain.tld
ServerAlias domain.tld
</VirtualHost>

As for why - I do it for type-ins. Probably less important than it used to be, since most browsers now will stick "http://www" in front of anything and try again before they give up on it. Enough people don't know that the www is part of the FQDN of the server they are trying to reach that I don't think I should count on them typing it.

It has occurrect to me to use 301 redirects instead, but that would just be more work. I might do it eventually to be just that much safer from a perception of duplicate content, but I really doubt SE spiders are that dumb.

Certainly, one could put different content on each of the domains if you so desired. I'm not sure why you would, though. It wouldn't exactly work as cloaking unless you had some control over who got links to www.domain.tld as opposed to domain.tld. Actually cloaking would be far easier than trying to maintain that kind of control over all links to your site.

soapystar

10:18 pm on Dec 26, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



thanks for that..it just leaves me confused as to why someone would ask me to link to there [domain.com...] when they have [domain.com...] as well...makes me nervous as to what is going on...

dingman

10:28 pm on Dec 26, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I know of a couple sites where [domain.com...] is the primary address, and [domain.com...] is a redirect. The first one that comes to mind is Slashdot.org. If you try www.slashdot.org, you get redirected to slashdot.org. If they are treating the domain without www as the primary site address, asking for links to point there makes perfect sense.

There might be some underhanded reason to do it this way, but I doubt it. I'm certainly not coming up with any ideas.

BjarneDM

10:36 pm on Dec 26, 2002 (gmt 0)

10+ Year Member



A little history lesson and some explaining:

[domain.com...] is *the* domain. The www-part was originally intended to reflect which server under the domain you accessed, thus as the internet started and you wanted to get www-content, you accessed the www-server, and html and www became synonymous. At present, the www-part can be anything and does get used for anything: [sales.domain.com...] ; [support.domain.com...] etc - you get the drift. Normally the domain both with and without the www serves the same content, but it's possible to server different content if you want to.

Personally, I'm using the something part of [something.domain.com...] to access pages deep inside the site as a kind of shortcut for certain functions so people end up at eg [domain.com...]

So, you've nothing to worry about - it's quite normal to see both versions used.

yours in happy hacking
Bjarne - København ; Danmark ; Europa

andreasfriedrich

10:53 pm on Dec 26, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hostnames take the form described in Section 3 of [RFC1034] [faqs.org] and Section 2.1 of [RFC1123] [faqs.org]: a sequence of domain labels separated by ".", each domain label starting and ending with an alphanumeric character and possibly also containing "-" characters.

[faqs.org...]

sun818

12:08 am on Dec 27, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



RewriteEngine On
RewriteCond %{HTTP_HOST}!^domain\.com
RewriteRule ^.*$ [domain.com%{REQUEST_URI}...] [R=301,L]

This is what is in my .htaccess file on the web root

It will take www.domain.com and permanently direct it to domain.com.

DaveAtIFG

12:23 am on Dec 27, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've been struggling with a drop in Google page rank at a site for several months. Late last week I found the site's page rank seems to be split between domain.com and www.domain.com and added a 301 redirect to get one dropped from the index and, hopefully, the other's PR boosted.

Robert Charlton

1:03 am on Dec 27, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Let me ask the same question at a really elementary level...

Suppose you want the url to always appear in the form [domain.com...] -- and that you want it to display that way whether or not the http and the www are included in the url typed in. What's the best way to set this up?

DaveAtIFG

1:33 am on Dec 27, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure it's the best way but this redirect will do the job:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^domainname [NC]
RewriteRule ^(.*) [domainname.com...] [R=301,L]

buckworks

5:56 am on Dec 27, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I think the biggest benefit of always having one's pages resolve to the same version (with OR without the www. bit) is that it helps to keep one's link popularity focused on one version, rather than split between both. I can't prove it, but I'm convinced that's a good thing. I always have my pages resolve to the non-www. version of my URLs, and I ask link partners to use that as well. I think trying to use one version consistently "won't hurt, might help". It certainly hasn't hurt in my experience.

This is also something to keep in mind if you have other domains pointing to the same content. Example: have yourmainsite.net resolve to yourmainsite.com, don't let yourmainsite.net stay in the address bar.

Robert Charlton

7:20 pm on Jan 5, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



DaveAtIFG - Mod Rewrite still makes me nervous, even with some great threads here on the board about it. I just put up my first .htaccess file less than a month ago.

Will PermanentRedirect also work in this case... and, if it would, what is the reason to use Mod Rewrite in preference to PermanentRedirect? I'm seeing that most experienced users on the board seem to favor Mod Rewrite (perhaps because it's more versatile?). Is it always preferable for redirects?

If I did use PermanentRedirect, what is the best syntax? I'd like all the urls to show with the www to avoid linking confusion.

jdMorgan

7:50 pm on Jan 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Robert Charlton,

RedirectPermanent won't do this job, because it is not "aware" of {HTTP_HOST} and therefore cannot discern when it does and does not need to redirect. There is no analogous function in RedirectPermanent to mod_rewrite's RewriteCond to provide for conditional redirects.

DaveAtIFG's rewrite above is very simple and effective. The biggest danger with mod_rewrite is if you make a typographical error, and then the results are immediate and obvious. :o Most can be "debugged" by looking at the raw error log - it usually identifies which line in .htaccess the server can't parse.

I have used the following, a hybrid of sun818's and DaveAtIFG's versions, for several years to redirect any request for any of my "registered, but non-standard domains" to www.mydomain.org:


Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mydomain\.org
RewriteRule ^(.*)$ http://www.mydomain.org/$1 [R=301,L]

Basically, if a visitor or 'bot requests mydomain.org, www.mydomain.com, WWW.MYDOMAIN.ORG, or any other non-standard variant of the domain name, they get neatly redirected to www.mydomain.org.

C'mon in, the water's fine! :)

Jim

Robert Charlton

6:52 am on Jan 6, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Thanks for the clarification...

>>C'mon in, the water's fine!<<

I'm testing it with my toe as we speak.