Awesome List Updates on Feb 02 - Feb 08, 2015

12 awesome lists updated this week.

🏠 Home · 🔍 Search · 🔥 Feed · 📮 Subscribe · ❤️ Sponsor

1. Awesome Talks

Functional Programming

Software Design

2. Awesome Projects Boilerplates

Websites

3. Awesome Clojure

Structural Migrations

HTML Manipulation

4. Awesome Hadoop

Hadoop

SQL on Hadoop

Libraries and Tools

Packaging, Provisioning and Monitoring

Search

Security

Websites

5. Awesome Elixir

Algorithms and Data structures

Applications

Authentication

Bittorrent

Build Tools

Code Analysis

Command Line Applications

Date and Time

Debugging

Email

Files and Directories

Framework Components

HTTP

Images

JSON

Miscellaneous

ORM and Datamapping

Protocols

Release Management

Templating

Testing

Text and Numbers

Third Party APIs

Other Awesome Lists

Reading

Websites

6. Services Engineering

Services Engineering Reading List / Books

7. Awesome Artificial Intelligence

Courses

Learning

8. Htaccess

Rewrite and Redirection

What we are doing here is mostly collecting useful snippets from all over the interwebs (for example, a good chunk is from Apache Server Configs (⭐3k)) into one place. While we’ve been trying to credit where due, things might be missing. If you believe anything here is your work and credits should be given, let us know, or just send a PR.

Note: It is assumed that you have mod_rewrite installed and enabled.

Rewrite and Redirection / Force www

Force www

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]

Rewrite and Redirection / Force www in a Generic Way

Force www in a Generic Way

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

This works for any domain. Source

Rewrite and Redirection / Force non-www

Force non-www

It’s still open for debate whether www or non-www is the way to go, so if you happen to be a fan of bare domains, here you go:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

Rewrite and Redirection / Force HTTPS

Force HTTPS

RewriteEngine on
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

# Note: It’s also recommended to enable HTTP Strict Transport Security (HSTS)
# on your HTTPS website to help prevent man-in-the-middle attacks.
# See https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security
<IfModule mod_headers.c>
    # Remove "includeSubDomains" if you don't want to enforce HSTS on all subdomains
    Header always set Strict-Transport-Security "max-age=31536000;includeSubDomains"
</IfModule>

Rewrite and Redirection / Force Trailing Slash

Force Trailing Slash

RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]

Security / Deny All Access

Deny All Access

## Apache 2.2
Deny from all

## Apache 2.4
# Require all denied

But wait, this will lock you out from your content as well! Thus introducing...

Security / Deny All Access Except Yours

Deny All Access Except Yours

## Apache 2.2
Order deny,allow
Deny from all
Allow from xxx.xxx.xxx.xxx

## Apache 2.4
# Require all denied
# Require ip xxx.xxx.xxx.xxx

xxx.xxx.xxx.xxx is your IP. If you replace the last three digits with 0/12 for example, this will specify a range of IPs within the same network, thus saving you the trouble to list all allowed IPs separately. Source

Now of course there's a reversed version:

Security / Allow All Access Except Spammers'

Allow All Access Except Spammers'

## Apache 2.2
Order deny,allow
Deny from xxx.xxx.xxx.xxx
Deny from xxx.xxx.xxx.xxy

## Apache 2.4
# Require all granted
# Require not ip xxx.xxx.xxx.xxx
# Require not ip xxx.xxx.xxx.xxy

Security / Disable Directory Browsing

Disable Directory Browsing

Options All -Indexes

Security / Disable Image Hotlinking

Disable Image Hotlinking

RewriteEngine on
# Remove the following line if you want to block blank referrer too
RewriteCond %{HTTP_REFERER} !^$

RewriteCond %{HTTP_REFERER} !^https?://(.+\.)?example.com [NC]
RewriteRule \.(jpe?g|png|gif|bmp)$ - [NC,F,L]

# If you want to display a “blocked” banner in place of the hotlinked image,
# replace the above rule with:
# RewriteRule \.(jpe?g|png|gif|bmp) http://example.com/blocked.png [R,L]

Security / Disable Image Hotlinking for Specific Domains

Disable Image Hotlinking for Specific Domains

Sometimes you want to disable image hotlinking from some bad guys only.

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^https?://(.+\.)?badsite\.com [NC,OR]
RewriteCond %{HTTP_REFERER} ^https?://(.+\.)?badsite2\.com [NC,OR]
RewriteRule \.(jpe?g|png|gif|bmp)$ - [NC,F,L]

# If you want to display a “blocked” banner in place of the hotlinked image,
# replace the above rule with:
# RewriteRule \.(jpe?g|png|gif|bmp) http://example.com/blocked.png [R,L]

Security / Password Protect a Directory

Password Protect a Directory

First you need to create a .htpasswd file somewhere in the system:

htpasswd -c /home/fellowship/.htpasswd boromir

Then you can use it for authentication:

AuthType Basic
AuthName "One does not simply"
AuthUserFile /home/fellowship/.htpasswd
Require valid-user

Security / Password Protect a File or Several Files

Password Protect a File or Several Files

AuthName "One still does not simply"
AuthType Basic
AuthUserFile /home/fellowship/.htpasswd

<Files "one-ring.o">
Require valid-user
</Files>

<FilesMatch ^((one|two|three)-rings?\.o)$>
Require valid-user
</FilesMatch>

Miscellaneous / Turn eTags Off

Turn eTags Off

By removing the ETag header, you disable caches and browsers from being able to validate files, so they are forced to rely on your Cache-Control and Expires header. Source

<IfModule mod_headers.c>
    Header unset ETag
</IfModule>
FileETag None

Miscellaneous / Set PHP Variables

Set PHP Variables

php_value <key> <val>

# For example:
php_value upload_max_filesize 50M
php_value max_execution_time 240

Miscellaneous / Custom Error Pages

Custom Error Pages

ErrorDocument 500 "Houston, we have a problem."
ErrorDocument 401 http://error.example.com/mordor.html
ErrorDocument 404 /errors/halflife3.html

9. Awesome Perl

File Manipulation / NoSQL Databases

List Manipulation / NoSQL Databases

10. Awesome Courses

Table of Contents / Legend

Courses / Systems

Courses / Machine Learning

11. Awesome Ruby

Code Analysis and Metrics

Database Drivers

Database Tools

Git Tools

Profiler and Optimization

12. Awesome Gametalks

Other Talks / TED Talks