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.

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

Discussion in 'General Discussion' started by friedbrain, Feb 2, 2012.

  1. friedbrain

    friedbrain Member

    Joined:
    Feb 2, 2012
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    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. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,474
    Likes Received:
    202
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Can you clarify what it is exactly you're hoping to do? It might be helpful for someone to assist more accurately.
     
  3. friedbrain

    friedbrain Member

    Joined:
    Feb 2, 2012
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    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. 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 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.
     
  5. friedbrain

    friedbrain Member

    Joined:
    Feb 2, 2012
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    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. friedbrain

    friedbrain Member

    Joined:
    Feb 2, 2012
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    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. 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
    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
     
Loading...

Share This Page