Results 1 to 16 of 16
  1. #1
    More Cheesier Than Ever Cheesehead's Avatar
    Join Date
    January 18th, 2005
    Location
    Land of The NFL Champs!
    Posts
    2,942
    Redirect All Pages of non-www to www
    I have used the following in my htaccess file successfully to redirect all non-www to www:

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

    I tried using this on a host that hosts multiple sites (as subdomains) and it did the following:

    It redirected http://mydomain. com to http://www.mydomain/mydomain/
    It also did the same thing if I typed in mydomain.com

    How can I fix this? Thanks in advance.
    Last edited by Cheesehead; August 4th, 2006 at 09:39 AM.
    This World is Not My Home
    We're gonna go inside, we're gonna go outside, inside and outside. . . And then we're gonna go go go and we're not gonna stop til we get across that goalline! Quotes from the movie Rudy, 1993

  2. #2
    Moderator MichaelColey's Avatar
    Join Date
    January 18th, 2005
    Location
    Mansfield, TX
    Posts
    16,232
    Here's the code I use on my sites (changed to yourdomain):

    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com
    RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]
    Michael Coley
    Amazing-Bargains.com
     Affiliate Tips | Merchant Best Practices | Affiliate Friendly? | Couponing | CPA Networks? | ABW Tips | Activating Affiliates
    "Education is the most powerful weapon which you can use to change the world." Nelson Mandela

  3. #3
    ABW Ambassador
    Join Date
    January 18th, 2005
    Location
    Los Angeles
    Posts
    4,053
    on a host that hosts multiple sites (as subdomains)
    Then that's add-on domains that reside in a folder instead of having their own root directory and control panel?

  4. #4
    More Cheesier Than Ever Cheesehead's Avatar
    Join Date
    January 18th, 2005
    Location
    Land of The NFL Champs!
    Posts
    2,942
    Quote Originally Posted by webworker
    Then that's add-on domains that reside in a folder instead of having their own root directory and control panel?
    Yes, correct. They reside in a folder.

    So, the REAL address of the index page of http:/ /addondomain.com/index.html is
    http:/ /primarydomain.com/addondomain/index.html

    Michael, I tried your suggestion but it made all non-www pages redirect to page-not-found. (The site is under construction so no harm done - Thanks Michael for helping out)
    Last edited by Cheesehead; August 4th, 2006 at 10:31 AM.
    This World is Not My Home
    We're gonna go inside, we're gonna go outside, inside and outside. . . And then we're gonna go go go and we're not gonna stop til we get across that goalline! Quotes from the movie Rudy, 1993

  5. #5
    ABW Ambassador
    Join Date
    January 18th, 2005
    Location
    Los Angeles
    Posts
    4,053
    Cheesehead I've passed up on a great hosting company's deal because of the add-on domains residing in a folder situation. Maybe you could ask tech support how to do it with that kind of set up and come back and share it with us here.

  6. #6
    Moderator MichaelColey's Avatar
    Join Date
    January 18th, 2005
    Location
    Mansfield, TX
    Posts
    16,232
    Try this, in the subdomain (not the main domain):

    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com/subdomain
    RewriteRule ^/(subdomain.*)$ http://www.yourdomain.com/$1 [R=301,L]
    Michael Coley
    Amazing-Bargains.com
     Affiliate Tips | Merchant Best Practices | Affiliate Friendly? | Couponing | CPA Networks? | ABW Tips | Activating Affiliates
    "Education is the most powerful weapon which you can use to change the world." Nelson Mandela

  7. #7
    More Cheesier Than Ever Cheesehead's Avatar
    Join Date
    January 18th, 2005
    Location
    Land of The NFL Champs!
    Posts
    2,942
    I submitted a help ticket to HostGator and am awaiting replies. I will let you all know what happens.
    This World is Not My Home
    We're gonna go inside, we're gonna go outside, inside and outside. . . And then we're gonna go go go and we're not gonna stop til we get across that goalline! Quotes from the movie Rudy, 1993

  8. #8
    More Cheesier Than Ever Cheesehead's Avatar
    Join Date
    January 18th, 2005
    Location
    Land of The NFL Champs!
    Posts
    2,942
    Quote Originally Posted by MichaelColey
    Try this, in the subdomain (not the main domain):

    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com/subdomain
    RewriteRule ^/(subdomain.*)$ http://www.yourdomain.com/$1 [R=301,L]
    I only have one htaccess file - it is in the public folder. Are you saying create another htaccess file in the subdomain folder? Would I use my primary domain name in place of "yourdomain" and my add-on domain in place of "subdomain"?
    This World is Not My Home
    We're gonna go inside, we're gonna go outside, inside and outside. . . And then we're gonna go go go and we're not gonna stop til we get across that goalline! Quotes from the movie Rudy, 1993

  9. #9
    Moderator MichaelColey's Avatar
    Join Date
    January 18th, 2005
    Location
    Mansfield, TX
    Posts
    16,232
    Yes and yes. See if that works.
    Michael Coley
    Amazing-Bargains.com
     Affiliate Tips | Merchant Best Practices | Affiliate Friendly? | Couponing | CPA Networks? | ABW Tips | Activating Affiliates
    "Education is the most powerful weapon which you can use to change the world." Nelson Mandela

  10. #10
    More Cheesier Than Ever Cheesehead's Avatar
    Join Date
    January 18th, 2005
    Location
    Land of The NFL Champs!
    Posts
    2,942
    I tried your very last suggestion with no luck.

    Then, .... I tried your first suggestion in the new .htaccess file created in the subdirectory folder. It is working!

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

    My Netscape 7.2 browser, however, seems to be stuck on the very first change I made when I enter only mydomain.com - all other entries are working fine in Netscape. The IE browser is doing the switch fine. I am thinking the Netscape browser is saving a setting or cached page or something? that will correct itself with time?

    I will try this with another under-construction site at this host.
    This World is Not My Home
    We're gonna go inside, we're gonna go outside, inside and outside. . . And then we're gonna go go go and we're not gonna stop til we get across that goalline! Quotes from the movie Rudy, 1993

  11. #11
    More Cheesier Than Ever Cheesehead's Avatar
    Join Date
    January 18th, 2005
    Location
    Land of The NFL Champs!
    Posts
    2,942
    I tried this on a second add on domain. All is working fine, even on the dreaded Netscape.

    So the key for this host (hostgator) is to put the redirect in the subfolder .htaccess file.

    Thanks ALL!
    This World is Not My Home
    We're gonna go inside, we're gonna go outside, inside and outside. . . And then we're gonna go go go and we're not gonna stop til we get across that goalline! Quotes from the movie Rudy, 1993

  12. #12
    More Cheesier Than Ever Cheesehead's Avatar
    Join Date
    January 18th, 2005
    Location
    Land of The NFL Champs!
    Posts
    2,942
    Thanks to all of you. Tech support did not seem to know what I was talking about however.

    I send them this: (actually, this is the third version of the same thing)
    I want my subdomains to redirect to the www page.

    So, if a user types in http://** ****.com, they are
    redirected to http://www.** ****.com
    For example, if you type in http://yahoo.com you are redirected to
    http://www.yahoo.com/

    They reply:
    Hi,

    Ok but you have to tell us exactly what it is your trying to do. Your being very limited with your info. So far all i got is that you want subdomains to redirect to the main domain. for that we would need to enable wildcard sub domains.

    Best Regards,
    ***
    HostGator Technical Support

    I closed the help ticket.
    This World is Not My Home
    We're gonna go inside, we're gonna go outside, inside and outside. . . And then we're gonna go go go and we're not gonna stop til we get across that goalline! Quotes from the movie Rudy, 1993

  13. #13
    Analytics Dude Kevin's Avatar
    Join Date
    January 18th, 2005
    Location
    Rochester, NY
    Posts
    5,904
    Oy. Bad support ticket

    Is it just as SEO efficient to drive the www traffic to non www? I would prefer to do it that way.
    Kevin Webster
    twitter: levelanalytics

    Kayak Fishing
    Web Analytics and Affiliate Marketing

  14. #14
    Moderator MichaelColey's Avatar
    Join Date
    January 18th, 2005
    Location
    Mansfield, TX
    Posts
    16,232
    I don't think there's a difference SEO-wise. I prefer the www version myself.
    Michael Coley
    Amazing-Bargains.com
     Affiliate Tips | Merchant Best Practices | Affiliate Friendly? | Couponing | CPA Networks? | ABW Tips | Activating Affiliates
    "Education is the most powerful weapon which you can use to change the world." Nelson Mandela

  15. #15
    ABW Ambassador MoneyBusiness's Avatar
    Join Date
    March 14th, 2006
    Posts
    2,051
    Quote Originally Posted by Cheesehead
    Hi,

    Ok but you have to tell us exactly what it is your trying to do. Your being very limited with your info. So far all i got is that you want subdomains to redirect to the main domain. for that we would need to enable wildcard sub domains.

    Best Regards,
    ***
    HostGator Technical Support

    I closed the help ticket.

    Customer service is a dying art.
    Follow my dog, Maya, and I, as we fumble around the affiliate marketing world: www.MarketingMaya.com
    Recent Project: Cheap Personal Checks (using DigitalQuill)

  16. #16
    More Cheesier Than Ever Cheesehead's Avatar
    Join Date
    January 18th, 2005
    Location
    Land of The NFL Champs!
    Posts
    2,942
    Quote Originally Posted by Noth
    Oy. Bad support ticket

    Is it just as SEO efficient to drive the www traffic to non www? I would prefer to do it that way.
    I think either way is fine, just not both.

    I had a site with a lot of inbound links both ways and it just got worse and worse rankings until I consolidated them. I am a believer now that it is important.
    This World is Not My Home
    We're gonna go inside, we're gonna go outside, inside and outside. . . And then we're gonna go go go and we're not gonna stop til we get across that goalline! Quotes from the movie Rudy, 1993

  17. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Using redirect pages with CJ. Is it legal?
    By steveyo6 in forum Commission Junction - CJ
    Replies: 2
    Last Post: October 26th, 2006, 02:56 PM
  2. www.ultimate-casino.net and www.prapanca-fm.com affiliate sites for sale!
    By master_watchmaker in forum Other Affiliate Networks
    Replies: 11
    Last Post: December 23rd, 2003, 10:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •