Welcome to WebmasterWorld Guest from

Forum Moderators: buckworks & webwork

Message Too Old, No Replies

DNS and non-www redirects for hosted shopping cart



3:25 pm on Apr 9, 2010 (gmt 0)

5+ Year Member

I signed up for a trial with a large hosted shopping cart SAAS. Using my own domain was very straightforward for this newbie because all I had to do was point the domain to their name servers. However, it turns out that they don't allow new customers to redirect non-www to www, so to avoid seo suicide I transfer the name servers back to me.

I've heard that there is a way to redirect the non-www to www using just DNS (on my own server I use htaccess), but I'm having trouble wrapping my thick skull around how to correctly implement it for my specific situation. Here is what I just put down in the dns, hopefully someone can tell me what I'm missing:

hostname | ip address/URL | Record Type
@ | | A
www | mystore12345.hostedcartdomain.com. | CNAME


12:03 am on Apr 10, 2010 (gmt 0)

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

DNS can't redirect as such - in this case, you can use the CNAME for www as shown above, but you will need to set the A record pointing to the IP address of a different server under your control, which will in turn issue the 301 redirect to the www version. (ie. there is no rule which says that the root domain and the www subdomain need to be on the same server.)


1:57 am on Apr 10, 2010 (gmt 0)

5+ Year Member

Hey, thanks for the help. You gave a very straightforward explanation that I think I comprehended. Let me repeat it back to you and see if I got it:

1. The DNS info I currently have is ok, except the IP address should be changed to my dedi instead of pointing at their servers.
2. I need to upload a .htaccess file with the following contents
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com
RewriteRule (.*) [mydomain.com...] [R=301,L]



3:29 am on Apr 10, 2010 (gmt 0)

WebmasterWorld Senior Member themadscientist is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

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

The preceding says: If the host is not (!) www.example.com to perform the redirect to example.com, so, it's usually a server error, because example.com's host will not be www.example.com. It might not error in your case, if your are 'pointing' example.com somewhere else, because it won't be checked by the .htaccess on a different server, but the correct way is:

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

# Note: I added the () and ? to leave it alone
# if the host is empty, because some older user
# agents don't send one.

# The preceding is the standard redirect, when the
# domain variations run from the same .htaccess but...

If you don't need to use another version of the domain name, since the .htaccess is on a different server than the www domain, you really don't need to check the host at all, because IMO you might as well redirect everything.

RewriteEngine on
RewriteRule (.*) http://www.example.com/$1 [R=301,L]


5:16 pm on Apr 10, 2010 (gmt 0)

5+ Year Member

excellent, thanks!

Featured Threads

Hot Threads This Week

Hot Threads This Month