Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Member
    Join Date
    Feb 2012
    Posts
    16
    cPanel/Enkompass Access Level

    Root Administrator

    Default Httpd.conf problems (don't like .htaccess)

    Hi everyone,
    after searching and trying all day I gave up, so here I am. I have a question:
    I need to put a few Apache rewrites and Deny ++ in httpd.conf. I understand that editing it manually means it will go away the next rebuild since Cpanel gets the info from the user's information.

    I am here Changes Contained within a VirtualHost Directive I have full root access.
    Can someone please distill this in a few lines? If my hostname /username is jones and I have Apache 2, the Cpanel admin is https but otherwise no ssl, what file name do I create? Where do I put it and any particular thing from my current stuff in htppd that needs to be left out?

    Thanks.

  2. #2
    cPanel Product Evangelist Infopro's Avatar
    Join Date
    May 2003
    Location
    Pennsylvania
    Posts
    7,894
    cPanel/Enkompass Access Level

    Root Administrator

    Default Re: Httpd.conf problems (don't like .htaccess)

    Can you clarify what it is exactly you're hoping to do? It might be helpful for someone to assist more accurately.

  3. #3
    Member
    Join Date
    Feb 2012
    Posts
    16
    cPanel/Enkompass Access Level

    Root Administrator

    Default Re: Httpd.conf problems (don't like .htaccess)

    Quote Originally Posted by Infopro View Post
    Can you clarify what it is exactly you're hoping to do? It might be helpful for someone to assist more accurately.
    Sorry for not making it clear. I have lots of custom apache rewrites for almost all my sites and I would rather not use .htaccess. How /where do I put that in the httpd.conf /cpanel data so it's not erased by the next update.

    Thanks again

  4. #4
    cPanel Staff cPanelTristan's Avatar
    Join Date
    Oct 2010
    Location
    somewhere over the rainbow
    Posts
    6,305
    cPanel/Enkompass Access Level

    Root Administrator

    Default Re: Httpd.conf problems (don't like .htaccess)

    You will need to provide exact specifics on some of those rewrites for us to know what needs to be done, since there are multiple locations rewrites can be done and the location to use is dependent on what exactly you are going to change.
    cPResources: Support Options | More Support Options | Forums Search | cPanel.net Site Search | Mailing Lists(Alt) | Docs
    -- Tristan, Forums Technical Analyst, cPanel Tech Support

    Submit a ticket | Check an existing ticket

  5. #5
    Member
    Join Date
    Feb 2012
    Posts
    16
    cPanel/Enkompass Access Level

    Root Administrator

    Default Re: Httpd.conf problems (don't like .htaccess)

    Hi Tristan,
    they need to be inside each virtual host.

    I am posting some and would appreciate any help. I'm lost. I have Apache 2 and have no SSL (other than accessing Cpanel)


    Code:
    RewriteEngine on
    RewriteRule ^(.+)-word$ /$1.php [L]
    
    RewriteEngine on
    RewriteRule ^go-out/(.*)$ /go-out.php?id=$1
    
    RedirectPermanent /test http://www.my-site.com
    
    
    <Directory /home/mydir/www/subdir>
    php_value output_handler none
    php_flag register_globals off
    php_flag safe_mode off
    </Directory>
    
    RewriteRule ^about/$ about.php
    
    RewriteCond %{QUERY_STRING} ^test$ [OR]
    RewriteCond %{QUERY_STRING} ^test1$
    RewriteRule ^$ http://www.mysite.com/? [R=301,L]
    
    RewriteCond %{HTTP_USER_AGENT} Zeus [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} ^GarlikCrawler/1\.1 [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} ^GarlikCrawler/\.1\.1 [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} Spinn3r [NC,OR]
    RewriteRule .* - [F,L]
    
    <Limit GET PUT POST>
    Order Allow,Deny
    Allow from all
    
    Deny from env=spammer
    
    Deny from 58.61 #soso
    Deny from 61.135 #TencentTraveler
    </Limit>
    
    <Directory /home/mydir/www>
    Options SymLinksIfOwnerMatch +IncludesNOEXEC +ExecCGI
    AllowOverride AuthConfig
    <IfModule mod_headers.c>
    <FilesMatch "\.(js|css|xml|gz)$">
    Header append Vary Accept-Encoding
    </FilesMatch>
    </IfModule>
    </Directory>
    
    <Directory "/home/mydir/www">
    Options FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
    
    ExpiresActive On
    ExpiresByType image/gif A2592000
    ExpiresByType image/png A2592000
    ExpiresByType image/jpg A2592000
    ExpiresByType image/jpeg A2592000
    ExpiresByType text/css A691200
    ExpiresByType application/javascript A691200
    ExpiresByType application/x-javascript A691200
    ExpiresByType text/javascript A691200
    ExpiresByType image/x-icon A2592000
    
    </Directory>
    
    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} ^Googlebot [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} ^Msnbot [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} ^Slurp [NC]
    RewriteCond %{THE_REQUEST} \.php
    RewriteRule \.php - [F]
    
    RewriteCond %{QUERY_STRING} utm_source=twitterfeed&utm_medium=twitter
    RewriteRule (.*) http://www.mysite.com$1? [R=301,L]
    
    RewriteEngine On
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php?\ HTTP/ [NC]
    RewriteRule ^(.*)index.php?$ http://www.mysite.com$1 [R=301,L]
    
    RewriteEngine On
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html?\ HTTP/ [NC]
    RewriteRule ^(.*)index.html?$ http://www.mysite.com$1 [R=301,L]
    
    RewriteEngine On
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.htm?\ HTTP/ [NC]
    RewriteRule ^(.*)index.htm?$ http://www.mysite.com$1 [R=301,L]
    
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^[0-9]+(\.[0-9]+){3} [OR]
    RewriteCond %{HTTP_HOST} ^mysite\.com
    RewriteRule ^(.*)$ http://www.mysite.com$1 [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^mail.mysite\.com
    RewriteRule ^(.*)$ http://www.mysite.com$1 [R=301,L]

  6. #6
    Member
    Join Date
    Feb 2012
    Posts
    16
    cPanel/Enkompass Access Level

    Root Administrator

    Default Re: Httpd.conf problems (don't like .htaccess)

    Tristan my other comment is pending,
    I have setup the directory at /usr/local/apache/conf/userdata/std/2/mycpanelusername/ (apache 2, no ssl)

    I am supposed to create a $includename.conf file in that folders. It's probably very obvious but what does $includename really mean? Do I have to name it a specific way with $include and name being ???

    And in the file do I put the same things I'd put on a normal conf file to control behavior within certain directories?

    Thanks

  7. #7
    cPanel Staff cPanelTristan's Avatar
    Join Date
    Oct 2010
    Location
    somewhere over the rainbow
    Posts
    6,305
    cPanel/Enkompass Access Level

    Root Administrator

    Default Re: Httpd.conf problems (don't like .htaccess)

    For $includename.conf, that stands for the name of the file, so name it whatever you want such as myinclude.conf would work. You should not name it with a $ in the file name.

    For a specific account, you would put it into /usr/local/apache/conf/userdata/std/2/username/ location where std is http, 2 is Apache 2 or Apache 2.2, and username is the cPanel username.

    After placing that content, you wouldn't use the distiller, you'd use the following to check the include and then add it:

    Code:
    /scripts/verify_vhost_includes
    /scripts/ensure_vhost_includes --user=username
    Again, replace username with the cPanel username. You might then want to run the following:

    Code:
    /scripts/rebuildhttpdconf
    /etc/init.d/httpd restart
    cPResources: Support Options | More Support Options | Forums Search | cPanel.net Site Search | Mailing Lists(Alt) | Docs
    -- Tristan, Forums Technical Analyst, cPanel Tech Support

    Submit a ticket | Check an existing ticket

Similar Threads & Tags
Similar threads

  1. Moving htaccess into httpd.conf
    By DAdams982 in forum Optimization
    Replies: 0
    Last Post: 09-27-2011, 10:53 AM
  2. moving elaborate mod_rewrite from .htaccess to httpd.conf
    By sneakyimp in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 03-07-2010, 10:10 PM
  3. /scripts/upcp causing problems with httpd.conf
    By WebIdentity in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 09-26-2009, 01:37 AM
  4. httpd.conf generation problems
    By bamnet in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 07-14-2007, 09:31 AM
  5. Httpd.conf problems
    By Stig in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 06-05-2005, 11:24 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube