edit all .htaccess files in /home

snaaps

Verified User
Joined
Jan 29, 2005
Messages
230
Location
Netherlands
Hi,

I just update the server from php5 in cgi to php5 in cli mode.
But a lot off user has a .htaccess file with the following content:
PHP:
<FilesMatch "\.(inc|php|php3|php4|php5|php6|phtml|phps)$">
AddHandler x-httpd-php5 .php
</FilesMatch>

How can i grep all this .htaccess files and delete this line for all .htaccess files?
 
Maybe you can do something like this;

/home/*/domains/*/public_html/.htaccess

Then use sed or perl to replace the lines for nothing?
 
edit post

command delete, it will work but remove to many other rules..

I used perl like this:
PHP:
perl -pi -e 's/<FilesMatch/#<FilesMatch/' /home/*/domains/*/public_html/.htaccess

But its delete all line with "<FilesMatch"
and the "/" is not allowed in this perl command

Is there a other soulition?

EDIT:
Used only this, that will do the trick!
PHP:
perl -pi -e 's/AddHandler x-httpd-php5 .php/#AddHandler x-httpd-php5 .php/' /home/*/domains/*/public_html/.htaccess
 
Last edited:
and the "/" is not allowed in this perl command

Basic perl states that all special perl characters need to be escaped if they are to taken literally. To use / as a literal it needs to be escaped like so \/
 
Back
Top