Www and non-www appear differently--how to fix?

My website appears differently depending on whether I view it as “www.wirestrungharp.com” or simply “wirestrungharp.com
The first one of these, the www, appears as I want it to; the other one does not.

My initial question is why and how does this happen? Why are there two versions of my website?

Then, how do I fix it? I suspect I need to do a “ReDirect” in my .htaccess file. However, in very many of the site’s pages I have given locations of links within the site as “http://wirestrungharp.com/desired__link” which defaults to “wirestrungharp.com/desired_link” which of course displays incorrectly. Must I go through all these pages and change the internal links to include the “www”?

Thank you in advance for any help or suggestions!

[font=verdana]Web servers are not automatically configured the same way, and the specs don’t require example.com and www.example.com to point to the same page. Most servers are set up to have them both giving the same page, but they are still represented as two separate URLs.

Fortunately, it’s very easy to solve this. In your .htaccess file, you just need some code along the lines of:

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

except that, obviously, you would replace example.com with your own domain name. This means that anyone going to the non-www version of the page is automatically redirected to the www version.[/font]

Perfect! Thank you, that did the trick and I don’t have to dip into every page I’ve coded to make the change!

Thank you also for the explanation. Good to know.

Aw, Stevie, you KNOW better than this!

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


RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\\.com$ [NC]
RewriteRule .? http://www.example.com%{REQUEST_URI} [R=301,L]

The use of example.com needs to have the dot character escaped (to specify the dot character rather than a metacharacter representing ANY character) and, because {HTTP_HOST} is not case sensitive, it requires the use of the No Case flag.

As for creating a new variable when you already have the {REQUEST_URI} available, IMHO, that’s a waste of CPU resources. Best to just get to the redirection with the {REQUEST_URI} (which also sorts out the question of Apache 1.x or 2.x with the leading /).