Saturday, October 1, 2011

htaccess Directory Listing Configurations

To prevent people from browsing your directoy, put this in your .htaccess file.
Option -indexes
OR:
IndexIgnore *

To allow people to see everything in your directory:
Option +indexes


To allow people to see everything except image files:
IndexIgnore *.gif *.jpg

How to Merge Tables

This is an example of how to insert all the missing rows from one table, tbl_backup, into another table, tbl_target. Since the primary_key is auto incremented, we will use col2 and col3 to identify unique rows.

INSERT IGNORE INTO `tbl_target`
  SELECT * FROM `tbl_backup` AS bkup
  WHERE ROW(bkup.col1, bkup.col2) NOT IN
    (SELECT orig.col1, orig.col2 FROM `tbl_target` AS orig);

Monday, April 11, 2011

Replace local home directory with an existing partition

Find the UUID of the partition:
$ blkid /dev/sda1
... or ...
$ ls -l /dev/disk/by-uuid

Edit /etc/fstab file:
UUID=xxxxxxxxx /home ext3 defaults,noexec,nosuid 1 2

Move home to old-home, then remount partition.
$ mv /home /old-home
$ mkdir /home
$ mount -o remount /home