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.

build_apache_conf groups all rewritecond and rewriterules together

Discussion in 'EasyApache' started by compuminus, Mar 10, 2011.

  1. compuminus

    compuminus Registered

    Joined:
    Apr 9, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    I have a sequence of rewrite rules in my httpd.conf as follows:

    RewriteCond Condition#1
    RewriteRule Rule#1
    RewriteCond Condition#2
    RewriteRule Rule#2

    However, whenever cpanel rebuilds the httpd.conf file, it groups all of the rewritecond and rewrite rules together, effectively breaking their functionality:

    RewriteCond Condition#1
    RewriteCond Condition#2
    RewriteRule Rule#1
    RewriteRule Rule#2

    Unless I'm overlooking something, this appears to be a MAJOR BUG. In my case, it's so bad that the rewrite rules create an infinite redirect and make the domain inaccessible until I correct the rewrite ordering.

    Please clarify if I am doing something wrong. For now I just avoid having cpanel rebuild the apache conf file, and just use the distiller followed by an httpd restart, but sometimes having cpanel rebuild the conf file is unavoidable, so I always have to keep a httpd.conf backup.
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    You would not add anything to httpd.conf directly. These should be done as includes instead.

    If you need them for the main configuration, then you can use /usr/local/apache/conf/includes area or WHM > Apache Configuration > Include Editor area.

    If these are for some select virtual host entries, then instead put them into /usr/local/apache/conf/userdata at the applicable location. Here's a discussion on using includes for the Virtual Host sections:

    Changes Contained within a VirtualHost Directive
     
  3. compuminus

    compuminus Registered

    Joined:
    Apr 9, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    So I would place all prior custom <Directory "PATH">xxxx</Directory> directives inside the pre_virtualhost_global.conf file? For some reason any changes in this file aren't getting incorporated into httpd.conf when running the two in sequence:

    /usr/local/cpanel/bin/apache_conf_distiller --update
    /scripts/rebuildhttpdconf
     
    #3 compuminus, Mar 10, 2011
    Last edited: Mar 10, 2011
  4. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Where in Apache do you normally put these includes? Do you really put them at the end of the Virtual Host section after all Virtual Host entries or do you normally put them before the Virtual Host entries? If you normally put them before those entries, you would want to use pre_main_global.conf and then rebuild Apache and restart Apache.

    Of note, you will *not* see the entries go into httpd.conf itself. The files are included, which means Apache reads any includes into the file. If you see post_virtualhost_global.conf as an include in httpd.conf file, then it is including the entries into the file and reading those entries.
     
  5. compuminus

    compuminus Registered

    Joined:
    Apr 9, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Thank you -- everything has now been sorted.
     

Share This Page