EA3 mime types and parsing .htm pages as php

tkerns

Active Member
Jun 13, 2007
34
0
56
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
AddHandler application/x-httpd-php5 .html .htm
AddType application/x-httpd-php5 .html .htm
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
 

d_t

Well-Known Member
Sep 20, 2003
243
3
168
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.
 

tkerns

Active Member
Jun 13, 2007
34
0
56
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.
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
 

d_t

Well-Known Member
Sep 20, 2003
243
3
168
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
 

tkerns

Active Member
Jun 13, 2007
34
0
56
Very useful little script!
It worked perfectly, thank you very much!

Tom