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.

moving elaborate mod_rewrite from .htaccess to httpd.conf

Discussion in 'General Discussion' started by sneakyimp, Mar 3, 2010.

  1. sneakyimp

    sneakyimp Member

    Joined:
    Mar 3, 2010
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    I've got a dedicated server using whm/cpanel and there is a particular domain being hosted which contains a very elaborate .htaccess file which is full of mod_rewrite rules, among other things. I've been asked to try and get the contents of this .htaccess file into the httpd.conf (or some appropriate include file) to improve performance.

    I've been reading this page and it's really confusing me:
    cPanel - The Easy Apache Configuration System - Adding Custom Directives to httpd.conf

    In the file usr/local/apache/conf/httpd.conf I see that there are two VirtualHost sections that appear to be relevant for my domain (which I'll call mydomain.com). The first listens on port 80 and the second is on 443. Seems to me that my apache directives in .htaccess would belong in this section. In the first section I see this:
    Code:
        # To customize this VirtualHost use an include file at the following location
        # Include "/usr/local/apache/conf/userdata/std/2/mydomain/mydomain.com/*.conf"
    
    In the second section I see this:
    Code:
        # To customize this VirtualHost use an include file at the following location
        # Include "/usr/local/apache/conf/userdata/ssl/2/mydomain/mydomain.com/*.conf"
    
    The problem with both of these is that the directory /usr/local/apache/conf/userdata does not exist, much less the full path to either of those files.

    If anyone could advise me on where I should be putting these elaborate rewrite rules, I'd be very grateful. The documentation on this is really hard to follow.
     
  2. cPanelDon

    cPanelDon cPanel Quality Assurance Analyst
    Staff Member

    Joined:
    Nov 5, 2008
    Messages:
    2,557
    Likes Received:
    7
    Trophy Points:
    38
    Location:
    Houston, Texas, U.S.A.
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Per the legacy documentation that is quoted: The include directory structure is not created automatically, but uses the following file structure. To note, this is also indicated in our newly-overhauled documentation: It is important to note that the include directory structure is not created for you. You will need to create and use the following file structures.

    Please be aware that our latest documentation is on the domain "docs.cpanel.net"; for quick access here is a direct link to the equivalent pages for EasyApache3 reference information about adding custom directives in the Apache virtual host configuration: Adding Custom Directives to httpd.conf >> Changes Contained within a VirtualHost Directive

    Via root SSH access, the following command may be used to help get started with creating the basic directory structure:
    Code:
    # mkdir -pv /usr/local/apache/conf/userdata/std /usr/local/apache/conf/userdata/ssl
    As an example, if your Apache version is "2" (e.g., 2.0 or 2.2) and the account involved has a username of "username" and a domain name of "domain.tld" then the following commands could be used to create appropriate directory structure (also via root SSH access):

    For a site without SSL:
    Code:
    # mkdir -pv /usr/local/apache/conf/userdata/std/2/username/domain.tld
    For a site with SSL:
    Code:
    # mkdir -pv /usr/local/apache/conf/userdata/ssl/2/username/domain.tld
     
  3. sneakyimp

    sneakyimp Member

    Joined:
    Mar 3, 2010
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Thank you so much for your response.

    I find myself very, very nervous about making these changes and would like to be clearer on the process. I had my hosting provider make some changes to support Subversion via apache and it would be devastating to lose those changes.

    I'm guessing that I'll need to add my custom directives to these two files and then use Webhost Manager / Easyapache to rebuild everything.

    I'd like to be able to roll back these changes if possible. What files are affected when I rebuild apache using EasyApache? Is there some kind of 'rollback' function?
     
  4. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,446
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
Loading...

Share This Page