# .htaccess Version 2.1 (from CMSms 1.11.x) - modified for CMS made simple

# Settings for some worse PHP installations
#php_flag magic_quotes_gpc off
#php_flag register_globals off
#php_flag session.use_trans_sid off

# Follow symbolic links (filesystem)
#Options +FollowSymLinks

# Permit Directory-Listing
Options -Indexes

# Define default file (Default-Handler)
#DirectoryIndex index.php

# Use mod_rewrite (user-friendly URLs)
RewriteEngine On
RewriteBase /

# Security settings
# Unterbindet, das fremde Seiten geladen werden
RewriteCond %{QUERY_STRING} ^(.*)=http://(.*) [OR]
# Blockiert libwww (Ausgangspunkt für diverse Hackversuche)
RewriteCond %{HTTP_USER_AGENT} ^libwww [OR]
# Blockiert Skripte, die versuchen, base64 encodierten Unsinn via URL zu versenden
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Blockiert Skripte, die einen a ********** Tag in der URL enthalten
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Blockiert Skripte, die versuchen, PHP GLOBALS Variablen via URL zu verändern
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Blockiert Skripte, die versuchen, eine _REQUEST Variable via URL zu verändern
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Zugriff verbieten
RewriteRule ^.* - [F]

# Redirect (301) request without . or / at the end
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_METHOD} !POST$
RewriteRule ^(.*) %{REQUEST_URI}/ [NE,R=301,L]

# Redirect page aliases
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]

# Apache module to compress text files (CSS/HTML/JS)
<IfModule mod_deflate.c>
#AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/json
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png|ico|flv|swf|mpg|mpeg)$ no-gzip dont-vary
Header append Vary Accept-Encoding
</IfModule>  

# Apache module to cache files
<IfModule mod_expires.c>
FileETag All
ExpiresActive On
ExpiresByType text/html "access plus 2 hours"
ExpiresByType text/css "access plus 2 hours"
ExpiresByType text/js "access plus 2 hours"
ExpiresByType text/x-js "access plus 2 hours" 
ExpiresByType text/javascript "access plus 2 hours"
ExpiresByType text/xml "access plus 2 hours"
ExpiresByType image/gif "access plus 1 years"
ExpiresByType image/jpg "access plus 1 years"
ExpiresByType image/jpeg "access plus 1 years"
ExpiresByType image/png "access plus 1 years"
ExpiresByType image/ico "access plus 1 years"
ExpiresByType audio/mpeg "access plus 1 years"
ExpiresByType application/javascript "access plus 2 hours"
ExpiresByType text/js "access plus 2 hours" 
ExpiresByType application/x-javascript "access plus 2 hours"
ExpiresByType text/x-js "access plus 2 hours" 
ExpiresByType application/pdf "access plus 2 hours"
ExpiresByType application/xml "modification plus 2 hours"
ExpiresByType application/x-shockwave-flash "access plus 2 hours"
</IfModule>
<IfModule mod_headers.c>
<FilesMatch "\.(ico|flv|swf)$">
Header set Cache-Control "max-age=31536000, public"
</FilesMatch>
<FilesMatch "\.(css|pdf|jpg|jpeg|png|gif)$">
Header set Cache-Control "max-age=2678400, public"
</FilesMatch>
<FilesMatch "\.(js|xml|txt)$">
Header set Cache-Control "max-age=2678400, private"
</FilesMatch>
</IfModule>

### Temp. Access Denied ###
#deny from all
#AuthName "Wartungsarbeiten"
#AuthType Basic
#AuthUserFile /path/to/.htpasswd
#require valid-user
#satisfy any

# EOF