Page 1 of 1

Enable both mod_php4 and mod_php5 in your .htaccess

Posted: Wed Mar 29, 2006 10:16 pm
by danglund
I had a problem where I had loads of .htaccess files like these:

Code: Select all

<IfModule mod_php4.c>
  php_value include_path "phplib/:/usr/local/share/pear"
  php_value display_errors TRUE
</IfModule>
Of course the ISP eventually upgraded to php5 and broke all my .htaccess files. I couldn't simple search and replace php4->php5, because then everything would break on my development server. The solution was to have both php4 and php5, and I used the following Textpad regular expression to do it:

Code: Select all

search: \(<IfModule mod_php4.c>\)\n\([[:print:][:space:]]+\)\n\([[:print:]]+\)\n\(</IfModule>\)

replace: \1\n\t\2\n\t\3\n\4\n<IfModule mod_php5.c>\n\t\2\n\t\3\n\4\n
The result

Code: Select all

<IfModule mod_php4.c>
  php_value include_path "phplib/:/usr/local/share/pear"
  php_value display_errors TRUE
</IfModule>
<IfModule mod_php5.c>
  php_value include_path "phplib/:/usr/local/share/pear"
  php_value display_errors TRUE
</IfModule>