Govind Malviya
Govind Malviya

Reputation: 13753

Difference between http://example.com and http://www.example.com

I getting a exception to retrieve session value in following condition.

  1. if I open site with this link http://example.com and assign session value
  2. Page will be redirect to the another site http://example1.com.
  3. some action at http://example1.com
  4. redirect to http://www.example.com (not http://example.com) and retrieve session value

in this situation system throw exception... but if i open site with http://www.example.com then working fine.

I have some questions

  1. Difference between http://example.com and http://www.example.com?
  2. how can resolve that problem because it is not necessary that user will type http://www.example.com.

Upvotes: 2

Views: 4749

Answers (6)

user2333811
user2333811

Reputation: 21

In the past many host servers created websites as subdomains under www., following THEN-current naming conventions.

We no longer need to do this.

There are no technical differences you will come across.

What matters is :

  1. You should stick with any one (say example.com), for better SEO rankings.
  2. Make sure the other site (that is www.example.com) points to example.com


This can be done by:

  1. CNAME is the DNS tag that maps an alias to the main name in the DNS record: in this case the "www." version of the name. With this solution surfers could include or exclude www. and reach the site either way.

  2. Making changes in the .htaccess file. Few links for reference:

Upvotes: 2

vrkansagara
vrkansagara

Reputation: 626

At the end of the day, http://www.domain.com and http://domain.com they are 2 diffrent domain name's if your aiming for a PR of 5 on http://domain.com then obviously don't expect to get it on http://www.domain.com

i do prefer www.

Upvotes: 0

Michel
Michel

Reputation: 23615

The first is that www is just another subdomain. we're used to type www.example.com, but it is nothing other than ttt.example.com or ppp.example.com

That's why in linux based server you normally have to put your sources in the www directory because it's a subdomain.

for the second there are multiple solutions. Fiddler showd me that when you type http://microsoft.com, microsoft answers with a 301 status (moved permanently) to http://www.microsoft.com

Upvotes: 1

Greg B
Greg B

Reputation: 14888

www. is a subdomain of example.com. If sessionState is set to use cookies to store the session ID, the domain name can affect sessions as cookies can be bound to domains (and subdomains).

Take a look at Wikipedia's article on cookies.

Upvotes: 1

Michael Christensen
Michael Christensen

Reputation: 1786

One option is to create a site in IIS that only serves the purpose of redirecting to the subdomain.

for example you have two sites configured.

www.example.com (main application example.com (configure redirection to http://www.example.com).

Im a bit confused by your question. It looks like your site is posting or redirecting to another site entirely? What duration do you have set for session and what cookie mode are you using?

Upvotes: 1

Ira Rainey
Ira Rainey

Reputation: 5209

Putting it very simply, http://site.com and http://www.site.com are two separate sites. This is because of the way DNS is setup for a domain name. You can configure the DNS record for a domain name to point both at the same IP address, or you could use a URLRewrite rule to force traffic one way or the other.

Take a look at this for more info:

Specify a canonical domain name for your site with IIS 7

Upvotes: 4

Related Questions