homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / WebmasterWorld / Domain Names
Forum Library, Charter, Moderators: buckworks & webwork

Domain Names Forum

DNS and non-www redirects for hosted shopping cart

5+ Year Member

Msg#: 4112989 posted 3:25 pm on Apr 9, 2010 (gmt 0)

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



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

Msg#: 4112989 posted 12:03 am on Apr 10, 2010 (gmt 0)

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.)


5+ Year Member

Msg#: 4112989 posted 1:57 am on Apr 10, 2010 (gmt 0)

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]



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

Msg#: 4112989 posted 3:29 am on Apr 10, 2010 (gmt 0)

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+ Year Member

Msg#: 4112989 posted 5:16 pm on Apr 10, 2010 (gmt 0)

excellent, thanks!

Global Options:
 top home search open messages active posts  

Home / Forums Index / WebmasterWorld / Domain Names
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved