The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

mod_rewrite and add-on domains

Discussion in 'General Discussion' started by shacker23, Dec 12, 2005.

  1. shacker23

    shacker23 Well-Known Member

    Joined:
    Feb 20, 2005
    Messages:
    263
    Likes Received:
    1
    Trophy Points:
    16
    I know this is more of an apache question than a cPanel question, but it connects to the way cPanel sets up add-on domains, so asking here.

    Given main domain blue.com and the add-on domain green.com, the customer doesn't want his Google pagerank confused by having blue.com and www.blue.com both equally available. All requests for www.blue.com should resolve to blue.com. So we set up this rewrite rule:


    Code:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^blue\.com
    RewriteRule ^.*$ http://blue.com%{REQUEST_URI} [R=301,L]
    
    Which works fine for blue.com. But because in cPanel green.com is a directory under blue's public_html, the .htaccess for blue.com also affects green.com. This is a problem in general, but here specifically, what happens is that the condition is matched for ALL requests on green.com, the rule kicks in, and the browser is redirected to blue.com.

    Is there a way to make the .htaccess for blue.com NOT affect green.com?

    And no, putting a separate/equivalent .htaccess in the green dir does not fix it :(

    Thanks,
    Scot
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    You have to turn off mod_rewrite in the .htaccess file for green.com:

    RewriteEngine off
     
  3. shacker23

    shacker23 Well-Known Member

    Joined:
    Feb 20, 2005
    Messages:
    263
    Likes Received:
    1
    Trophy Points:
    16
    Ah, of course. And then if I wanted green.com to have its own set of rules, I assume I could just turn it back on in its own .htaccess.

    Will experiment. Thanks.
     
Loading...

Share This Page