Find the Htaccess Location

Especially when working on foreign systems/servers it might be hard to determine where the .htpasswd file would go if you need an access restricted area while developing the website without taking the server offline.

Here is a short PHP script on how to find it:

*Info: Save this as findHtPasswd.php and run it on the host like https://this.host.com/findHtPasswd.php, copy the code and create a simple .htaccess file pointing to the correct location.

Read more

Force Ssl Redirect With Apache2

The easiest way to permanently redirect (301), when dealing with apache2 that is, would be these three lines of code below:

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

The way this works in NGINX is just as easy:

server_name git.server.com; 
## Don't show the nginx version number, a security best practice 
server_tokens off; 
location / {
	return 301 https://git.server.com:443$request_uri;
}
Read more

A Linux Commands Overview

Some useful terminal commands in Linux or OSX

-> List all cronjobs from all users and services (all existing)

for user in $(cut -f1 d: /etc/passwd); do crontab -u $user -l; done

-> For all users and services in /etc/passwd

for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done

-> A nicer list for each user in /etc/passwd

-> Find and delete 10 days old files in /tmp

find /tmp -ctime +10 -exec rm -rf {} +

-> Zip and Tar over SSH compression

Read more

Linux Installation of Zsh and Oh My Zsh

This can be done in two or three easy steps:

  1. sudo apt-get install zsh curl git
  2. sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
  3. (optional, must be installed for the agnoster theme for example (see here)) sudo apt-get install fonts-powerline (echo "\ue0b0 \u00b1 \ue0a0 \u27a6 \u2718 \u26a1 \u2699" to test)
Read more