ARCHIVES_DATE june 2019

Convert all htaccess files to httpd.conf directives


This post is for the Apache web server, I created a simple script that will do the job. You may use it in Wordpress or in many CMS, surely this script will be useful in a lot of situations. It will help you to increase the speed and security of your site. Requirements: root access.

#! /bin/bash
b=$(find $1 -name .htaccess)
for p in $b; do if [[ -s "$p" ]] ; then a=$(dirname $p); echo \<Directory \"$a\"\>; cat $p; echo; echo \</Directory\>; echo; fi; done

You only have to specify the website directory and it fill search for all .htaccess files in sub-directories, then it will print the directives for the httpd.conf file, you can invoke the script like this:

./script.sh /var/www/html


Add the resulting configuration manually to httpd.conf and don't forget to add AllowOverride None to the root directory, in this way my website speed increased noticeably! Also security increased. Please notice that you may end with a duplicated entry for the base directory, so please check it carefully. I read that a hacked website may include malicious code in the .htaccess files, so please check the code before adding into the config file.


All system messed when installing an application


It has been a while since the last time I did a whole system update in Slackware, this time I tried to install audacious, an audio player included in the official repos, the first thing to do was updating the list of files:

slackpkg update

Then I installed audacious:

slackpkg install audacious

At certain point it seems that it asked me to replace configuration files. It messed with my whole system. Installing just an application messed with all my /etc directory. So my advice is that you always check the configuration files that will be updated no matter what you are doing or the distro you are using.

How I solved it?

The next day I realized that I had lots of .orig files in /etc. So I restore all my important config files.

find /etc -name *.orig

Notice that I lost my /etc/rc.d/rc.local , there was not an /etc/rc.d/rc.local.orig


Script for concatenation


Here a tip for using split and cat, you can use this simple bash script for concatenating the pieces of the file, first you have to change the current directory to the one with the current files part.

You will be asked by the base name and the extension of the file. Easy!

#! /bin/bash
read -p "Base name: " basi
read -p "Extension: " ext
cat $(ls $basi*) > $basi.$ext