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.

disable .htaccess

Discussion in 'General Discussion' started by bt4, Aug 1, 2011.

  1. bt4

    bt4 Well-Known Member

    Joined:
    Jul 1, 2010
    Messages:
    69
    Likes Received:
    0
    Trophy Points:
    6
    Hi,

    i want disable .htaccess for all hosts,
    if some upload or make new file name by .htaccess Automaticaly deleted or hided and get error 500 to this host
    i dont want it work on my server
     
  2. SoftDux

    SoftDux Well-Known Member

    Joined:
    May 27, 2006
    Messages:
    983
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Johannesburg, South Africa
    cPanel Access Level:
    Root Administrator
    You would probably need to write a custom script which runs via cron on a regular basis to find all .htaccess files and delete them

    But, bear in mind that you'll probably break many user's websites by doing this
     
  3. bt4

    bt4 Well-Known Member

    Joined:
    Jul 1, 2010
    Messages:
    69
    Likes Received:
    0
    Trophy Points:
    6
    i dont want find htaccess from websites, if i delete them , hosts can make new one again, i want disable .htaccess
     
  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
    Hello,

    You should have a section similar to the following:

    Code:
    <Directory "/">
    Options All
    AllowOverride All
    </Directory>
    Whatever it has listed for AllowOverride line, change to:

    Code:
    AllowOverride None
    At that point, then distill the changes, rebuild Apache and restart Apache:

    Code:
    cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak110802
    /usr/local/cpanel/bin/apache_conf_distiller --update
    /scripts/rebuildhttpdconf
    /etc/init.d/httpd restart
    No further .htaccess files should work after this is set. It basically stops overrides at / level and higher using .htaccess files.
     
  5. bt4

    bt4 Well-Known Member

    Joined:
    Jul 1, 2010
    Messages:
    69
    Likes Received:
    0
    Trophy Points:
    6
    thanks

    but how i can active htaccess just for one host or tow?
     
  6. 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 cannot. It is one or the other.

    Also, your original request did not include this:

    It is probably possible to give another <Directory "/pathtodirectory"> option to allow AllowOverride, but I didn't test that option, since it wasn't what was asked.

    Edit: So, upon testing, this works:

    Code:
    <Directory "/">
        Options All
        AllowOverride None
    </Directory>
    
    <Directory "/home/username">
        Options All
        AllowOverride All
    </Directory>
    This would again need to be distilled, Apache rebuilt and Apache restarted. The username in the path would need to be revised to the actual cPanel username. At that point, the account in question can have an .htaccess file working.
     
  7. bt4

    bt4 Well-Known Member

    Joined:
    Jul 1, 2010
    Messages:
    69
    Likes Received:
    0
    Trophy Points:
    6
    i test it, and working, before test it i have some problem, .htaccess showed from some host, and hided from some hosts some
    from some hosts when i make htaccess it get hided Automatically
    but from some host showed but ddt work
    what is the problem of that?
    from my friend server when some one upload .htaccess this Host Automaticaly get Error 500
    how he do that?
     
  8. 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
    Unfortunately, I am unclear on what is being asked this time. Please try to be clear with proper grammatical sentences on what is needed or being requested.

    The above method should be working for what was asked already. If this is not sufficient for reaching the goal required, when it does actually work to provide no .htaccess allowed for most accounts and allow some to use one, then I cannot really say why anything else is needed at this point.
     
  9. shahjashua0

    shahjashua0 Registered

    Joined:
    Aug 4, 2011
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    u can try this code to avoid such a problem

    cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak110802
    /usr/local/cpanel/bin/apache_conf_distiller --update
    /scripts/rebuildhttpdconf
    /etc/init.d/httpd restart
     
  10. 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
    I had already provided those same commands earlier when noting how to distill changes upon revising the AllowOverride section of httpd.conf file. I'm not certain if that was what was being asked by bt4
     
Loading...

Share This Page