How can I force my site to add "www." before the URL if visitors don't enter it?

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

How can I force my site to add "www." before the URL if visitors don't enter it?

Scenario:Customer types in "example.com" when trying to enter your website.In most cases this will let them get to your site fine. BUT ... if you've configured your site to use "www.example.com" in all the URLs it generates, then the customer's next click will attempt to change the URL and (on some servers) may log them out if they were attempting login, etc. This is because of the way PHP session security works with setting a session cookie tied to a domain name, etc. The technical details can be read online elsewhere.Also, in Internet Explorer, if you are using some fancy flyout CSS effects the addon script that drives this may not be "found" because of the change in domain name ... meaning that the menu won't work until the customer first does another click on your site.

There are a couple things to keep in mind to handle this:

Always be consistent in your use of your domain name. If you're going to use "www.example.com", be sure to use it exactly that way everywhere. Don't drop the "www." unless you do it consistently in all places.

In your SSL certificate, when you register one, you must specify a domain name. Again, be consistent. If you're using "www." in your URL, use it in your SSL certificate too.

Ensure that your hosting company has configured a "www." address as an alias to your domain name ... so that "both" will work -- otherwise visitors might get a "domain not found" error instead of your site.

If you are running on an Apache webserver, you can set up a .htaccess rule to automatically add the "www." into the URL if the customer forgets to include it. The following is what you'd put in your .htaccess to accomplish this: