开发者

Editing multiple .htaccess files

We got around 500 websites on our server and all of them has their own user directory.

/home/siteA/public_html/
/home/siteB/public_html/
/home/siteC/public_html/

All of them has its own .htaccess file and its duplicated.

What i wanna do is comment out last row of each file. i开发者_StackOverflows it possible to do it without actually editing all files by hand.


Yes. Assuming you have a list of which directories are sites in say sites.txt, just loop over them like this:

while read sitename; do 
    sed -ri "$ s/(.+)/#\1/" /home/$sitename/.htaccess
done < sites.txt

Just make sure that you don't have a bunch of empty lines at the end of your files; this will comment out the last line, not the last line with content. If you need to do that, it will become much more difficult.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜