Extracting and Compressing Tar.gz via command line
With explaining the inner workings of all the switches, you can extract / compress .tar.gz archives easily with the following codes:
Ubuntu Apache2 mod_rewrite not working
So I’ve been delving further into getting a development server running, and have built a fully functioning webserver running with Ubuntu on an Oracle VirtualBox. Who says you need flash hardware?!
Htaccess temporary redirect while undergoing maintenance
Developing a site and you want to have a nice temporary page for visitors? Drop in this code at the top of your .htaccess file and make your pretty 'Coming Soon' page in the root called 'offline.html'.
Track down the largest files and folders with 1 command
Struggling to track down where your hard drive or web server space is going? This command prints out the 20 largest files and folders:
Convert file extensions to lowercase
Having issues with upper and lowercase file names? Use this script to programatically convert all extensions to lowercase. It will affect all files within the current folder.
Running uTorrent from command line on Ubuntu
You can relatively easily set up uTorrent to run as a webUI from your webserver. This requires Ubuntu 9+ and a download of uTorrent. Make sure you also install PeerGuardian!
Avoid locking your web-uploaded files
Out of the box, most webservers will run Apache processes as user 'www-data', which has it's own group. If you then try to move/delete/edit any files created by this user via FTP or SSH, you are likely to be denied access. This often happens when files are uploaded with a CMS. Login via SSH as root and drop in this command which will add your user to the www-data group. This will allow your user to edit files that are shared within the www-data group. Win!
Remote rsync transfers using SSH on a non-standard port
Often you'll need to transfer a file from your webserver to your local environment. This can be a bit tricky if your local environment is a headless webserver (or you just don't like FTP). With this command you can transfer your files over an SSH connection, when your remote server is running a non-standard SSH port.
Rewrite based on domain
Recently I needed to redirect traffic when the domain was NOT www.website.co.nz. This is often handy if you have several domains hinged off one virtual host.
Removing www from your site
Personally I prefer web URL's to exclude www, and so I implement the following code on all project's .htaccess file: