Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Default Mod Rewrite on Dedicated Server

5:15 pm on May 25, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Mar 16, 2004
votes: 0

I have a question with regards to the htaccess files or http.conf files in Apache with regards to redirection rules.

What I'm trying to find out is if it is possible to do have a setting somewhere in apache so that by default all instances of domainname.com (without the www) are always redirected to www.domainname.com.

Right now, the client has to create the domain name in their Web Host Manager screen, then they have to modify an htaccess file and then upload it for each domain in order to do the redirect so that there is not duplicate content served by Apache on both domainname.com and www.domainname.com

Instead of having to do this manually for each domain, I was wondering if there would be a better, more automated solution in terms of a wildcard entry somewhere in Apache or in httpd.conf that says

whenever a new domain is created, just always redirect the content to the www. version of each site, without having to manually either create rules in the httpd.conf file or setup individual htaccess files in each domains folders.

Has anyone run into this situation before, and if so, do you have any ideas to automate the process?

Thank you.

6:06 pm on May 25, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
votes: 0

It's easy enough to implement in httpd.conf or conf.d, but I wouldn't recommend it.

One point that's often missed in the 'gripe session' threads about domain canonicalization --where the posters complain that Gooogle or other SEs should 'handle it' automatically-- is that "www" and non-www are not the same host.

Technically, "www.example.com" is a subdomain of "example.com" and need not contain the same content. There is absolutely nothing special about "www" -- it is just another arbitrary subdomain name, like "search" or "shopping" as used on major portals.

However, in the old days, "example.com" was used as the 'intranet' doamin for employees inside a company, while "www.example.com" was the publically-accessible Web site. This made the distinction clear, and made it easy to set up a firewall to protect the private intranet.

Now, with the commoditization of Web sites, the distinction is not clear if there is no 'intranet' -- that is, if there is no separate server space for private company use on a site. This is much more common now that anybody can have a domain and a Web site, and they're not reserved for large corporations any more.

So, the problem you would face is that some users would want "www" as the canonical name, some would want the non-www version, and some might want to keep both so that they could have separate content on the two hostnames.

If you take a look at some of the aforementioned canonicalization threads here on WebmasterWorld, you'll see that the split between those who prefer non-www vs. those who prefer www means that you'd make a good number of clients (or potential clients) unhappy.

Best practice would be to leave it as a cpanel settings, but emphasize in your customer welcome letter and FAQ pages that picking one or the other is highly recommended.


12:01 am on May 28, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Mar 16, 2004
votes: 0


Thanks for your response and for the detailed info in terms of what else to watch out for.

I do however, have a client who has their own server and I'm looking for a solution to have all of their sites come up as www.domain name because as it stands now, I'm the one that has to go in and manually upload the .htaccess file individually, and this takes way too much time that I could be spending doing much more productive things. There's no one else hosted on this server--just their sites. I understand that it won't be a solution for everyone and all servers, but could you share with me the solution on what to put in the httpd.conf file so that at least for this one client, I'm not stuck doing each and every site by hand?

Thank you!