|Non-www is not indexed|
Without www is not indexed
Please tell me the reason, If we use "http://www.sample.com" returns results in google, but "http://sample.com" returns "did not match any documents".
The inner page URLs are relative path.
Unless the "no-www" urls have different content from the "with-www" urls, you don't want to see both versions in Google -- it could be a sign of trouble. Two urls for the same content is a duplication issue that has buried many a site's rankings.
Duplicate Content - Get it right or perish [webmasterworld.com]
To answer your question about why the non-www doesn't show, there would have to be links to the non-www from the site or from outside the site. In addition the non www form would also have to be a valid server alias.
However, tedster is correct that unless the content at the non-www form is different than that at the www form you are looking at some form of a Google wash (duplicate content issue/problem/whatever).
You really need to be careful.
[edited by: theBear at 4:27 pm (utc) on Sep. 21, 2006]
For Google, [sample.com...] and [sample.com...] are as different URLs, as [home.sample.com...] and other subdomains. And additionally, Google hates duplicate content available under multiple addresses. So even if you set your server up to serve the content for both URL forms, it would ruin your rankings if Google indexed both versions.
If you want your site to work if visitor writes either "www.sample.com" or "sample.com" in browers, you should choose one of these versions as canonical, as set up 301 redirect from other versions to this one. The same, if you own multiple domains for one site, for example, with different spellings of company name, you should 301 redirect all of them to the proper version, if you want to be in accordance with Google guidelines.
If there is a proper 301 redirect from non-www to www version, or the other way round, and some backlinks to both versions, Google responds properly to both version without duplicate content issues. Also setting the preferred URL version in Google webmaster tools can help. But don't ever allow Google to index both URL versions without telling it which one is canonical!
As said above, you are in big trouble if both show up in the index.
If you haven't already done so, then now is the exact right time to install a site-wide 301 redirect from non-www to www and make sure that non-www can never appear in the index.
I registered a new domain name and I found that the non-www had a PR 2, should I use it as the main website, or will the PR disappear after some time
If non-www has existing backlinks (having PR might indicate that), and with-www does not, you might consider using no-www as your domain and redirecting (301) from with-www to no-www.
I say "might" because pre-existing links could do you no good if they are off-topic for your new content. I think you need to research things a bit.