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.

EA3 mime types and parsing .htm pages as php

Discussion in 'General Discussion' started by tkerns, May 3, 2008.

  1. tkerns

    tkerns Active Member

    Joined:
    Jun 13, 2007
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    6
    I am finally reluctantly having to rebuild apache and php, using EA3.
    This server has 300 accounts on it. Maybe a third of which have .htaccess files with the following directives somewhere in them, to parse .htm and .html pages as php
    Code:
    AddType text/x-server-parsed-html .html .htm
    AddHandler application/x-httpd-php .htm .html 
    
    After rebuilding apache and php5 (i am upgrading from 5.23 to 5.26, and suphp with suexec on) none of the html pages that were supposed to be parsed as php work. On top of that, many sites, if you go to http://www.domain.com (ie dont specify the index page) ask you if you want to download the page
    After much searching I have discovered that now I need to use
    in those htaccess files, and it now appears to work.
    Is there a workaround to having to replace those 2 lines in over a hundred htaccess files?

    If not, what about a script that would search for the above line (or lines) and replace them with the appropriate ones, and keep the file permissions the same?

    I would have hoped that the update_mime_types script would have done that, but it seems to randomly put a comment (#) in front of some addhandler directives.

    Anybody have any suggestion?

    Thanks!

    Tom
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

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

    d_t Well-Known Member

    Joined:
    Sep 20, 2003
    Messages:
    243
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Bucharest
    You can search for .htaccess files that contains x-httpd-php and build a list of those files

    Code:
    find /home -name .htaccess -exec grep x-httpd-php {} \;
    Then you can use replace tool (comes with mysql) to make changes in those files.
     
  4. tkerns

    tkerns Active Member

    Joined:
    Jun 13, 2007
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    6
    Thanks.

    I already have a list of a hundred or so domains. I am not familiar with the replace tool. Could you point me in the right direction?

    Basically I want to search for
    AddType text/x-server-parsed-html .html .htm
    in all .htaccess files, and replace it with
    AddType application/x-httpd-php5 .html .htm

    Thanks!
    Tom
     
  5. d_t

    d_t Well-Known Member

    Joined:
    Sep 20, 2003
    Messages:
    243
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Bucharest
    syntax for replace is:

    replace "search_string" "replace_string" -- /path/to/file

    and the code will be:

    Code:
    find /home -name .htaccess -exec grep -l x-httpd-php >> hta_list {} \;
    for i in `cat hta_list`; do replace "AddType text/x-server-parsed-html .html .htm" "AddType application/x-httpd-php5 .html .htm" -- $i; done
     
  6. tkerns

    tkerns Active Member

    Joined:
    Jun 13, 2007
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    6
    Very useful little script!
    It worked perfectly, thank you very much!

    Tom
     
Loading...

Share This Page