Thursday, October 8, 2015

Centos disk space allocation

You need to unmount a filesystem to shrink it. So, for /home you'll want to be log in as root and umount /home. If it's 'busy'. You may need to stop any processes using files here.

Then, shrink the file system to just below your targeted logical volume size.

resize2fs /dev/mapper/vg_nastgweblls01-lv_home 99G

Shrink the logical volume to the targeted size.

lvreduce -L 100G /dev/mapper/vg_nastgweblls01-lv_home

Grow the filesystem to the logical volume's capacity.

resize2fs /dev/mapper/vg_nastgweblls01-lv_home

The reason I do it this so I don't have to do any math and keep the filesystem the size of the container. A bit lazy, but it works great.

Now, you have free space to grow root.

lvextend -L 75G /dev/mapper/vg_nastgweblls01-lv_root
resize2fs /dev/mapper/vg_nastgweblls01-lv_root


* remembered that I need to mount the home drive

mount /home

Tuesday, September 8, 2015

How to make a Case-insensitive url redirect to a case-sensitive url


Ex:
https://example.com/example/index.html to https://example.com/ExamPLe/index.html

RewriteEngine On
RewriteCond %{REQUEST_URI} !/WebMaster/ 
RewriteRule ^/?webmaster/(.*) http://www.example.com/WebMaster/$1 [NC,R=301,L]

Preventing Directory Listing

Preventing Directory Listing

Do you have a directory full of images or zips that you do not want people to be able to browse through? Typically a server is setup to prevent directory listing, but sometimes they are not. If not, become self-sufficient and fix it yourself:

    IndexIgnore *

The * is a wildcard that matches all files, so if you stick that line into an htaccess file in your images directory, nothing in that directory will be allowed to be listed.

On the other hand, what if you did want the directory contents to be listed, but only if they were HTML pages and not images? Simple says I:

    IndexIgnore *.gif *.jpg

This would return a list of all files not ending in .jpg or .gif, but would still list .txt, .html, etc.

And conversely, if your server is setup to prevent directory listing, but you want to list the directories by default, you could simply throw this into an htaccess file the directory you want displayed:

    Options +Indexes

If you do use this option, be very careful that you do not put any unintentional or compromising files in this directory. And if you guessed it by the plus sign before Indexes, you can throw in a minus sign (Options -Indexes) to prevent directory listing entirely--this is typical of most server setups and is usually configured elsewhere in the apache server, but can be overridden through htaccess.