Enable both mod_php4 and mod_php5 in your .htaccess

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
danglund
Posts: 7
Joined: Mon Jul 14, 2003 9:39 am

Enable both mod_php4 and mod_php5 in your .htaccess

Post 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>
Post Reply