How do I use .htaccess in the root folder without affecting sub-domains?

Discussion in 'Web Hosting' started by medoomi, Sep 24, 2009.

  1. medoomi

    medoomi New Member

    Joined:
    Sep 24, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    The solution might be quite simple, but I'm having trouble locating it. Can anyone direct me the right place?

    I host six websites with separate domains from one server (one of which is a primary domain, hosted in the root folder)

    Presently, any .htaccess 301 folder re-directs that I put in the in the root folder affect not only the primary domain, but all sub-domains as well.

    How do I avoid this?
    Thanks.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    There is a way you can Test the Host and only take action for your main host and not sub-domain.
     
  3. seopeter

    seopeter New Member

    Joined:
    Sep 25, 2009
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    0
    Have you hosted direct or using any panel
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Could not understand what you are asking?
     
  5. medoomi

    medoomi New Member

    Joined:
    Sep 24, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Thanks so much for your reply. That sounds really helpful. Could you enlarge--I'm assuming you mean code for the .htaccess file. Do you know where I can look this up?

    Thanks
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    You should use something like this
    Code:
    RewriteCond %{HTTP_HOST} my\.go4expert\.com$ [NC]  
    RewriteRule ........
    
     
  7. medoomi

    medoomi New Member

    Joined:
    Sep 24, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    I've tried the following, but can't figure why it's not working
    (I'm not sure of the right way to write this. I put myhostname for the domain name without the http and myhostnamewithhttpatthefront for the domain name with the http)

    Code:
    RewriteCond %{HTTP_HOST} myhostname$ [NC]
    RewriteRule /gallery.html myhostnamewithhttpatthefront/gallery.php [r=301,nc]
     
  8. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Probably then post the exact one but you would need double digit post count for that and making genuine posts in the forums can get you that easily
     
  9. medoomi

    medoomi New Member

    Joined:
    Sep 24, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    OK, cool, thanks for your replies (I quickly get over my head on this one :) )
     
  10. medoomi

    medoomi New Member

    Joined:
    Sep 24, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    OK, I've got it running, using the following code:
    (I didn't realise the backslashes were necessary for the periods), and that I should not begin the rewriterole with a forward slash)

    RewriteCond %{HTTP_HOST} my\.go4expert\.com$ [NC]
    RewriteRule ^gallery.html$ newurl [r=301,nc]
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice