Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Mar 2010
    Posts
    7

    Default moving elaborate mod_rewrite from .htaccess to httpd.conf

    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. #2
    cPanel Quality Assurance Analyst cPanelDon's Avatar
    Join Date
    Nov 2008
    Location
    Houston, Texas, U.S.A.
    Posts
    2,555
    cPanel/Enkompass Access Level

    DataCenter Provider

    Default

    Quote Originally Posted by sneakyimp View Post
    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.
    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. #3
    Member
    Join Date
    Mar 2010
    Posts
    7

    Default

    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. #4
    cPanel Product Evangelist Infopro's Avatar
    Join Date
    May 2003
    Location
    Pennsylvania
    Posts
    7,894
    cPanel/Enkompass Access Level

    Root Administrator

    Lightbulb

    Yes, you can roll back to the last configuration (Previously Saved Config) if needed. More on that in the docs:
    SavingCustomOptions < EasyApache3 < TWiki

    Apache & cPanel/WHM

Similar Threads & Tags
Similar threads

  1. question about using .htaccess and mod_rewrite.c
    By lottocheatah in forum Security
    Replies: 1
    Last Post: 05-24-2011, 05:08 PM
  2. Preserve amends to /etc/httpd/conf/httpd.conf ?
    By robocrop in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 08-14-2010, 02:08 AM
  3. Replies: 0
    Last Post: 06-27-2010, 06:31 PM
  4. enabling mod_rewrite module in http.conf
    By runee in forum New User Questions
    Replies: 4
    Last Post: 07-01-2009, 05:08 AM
  5. Using .htaccess for mod_rewrite commands
    By fwwebs in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 09-13-2006, 01:34 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube