# .htaccess Version 2.1 (ab CMSms 1.11.x) - angepasst für CMS made simple

# Einstellungen für schlecht konfigurierte PHP Installationen
#php_flag magic_quotes_gpc off
#php_flag register_globals off
#php_flag session.use_trans_sid off

# Symbolischen Links (Dateisystem) folgen
#Options +FollowSymLinks

# Verzeichnis-Listing verhindern
Options -Indexes

# Standard-Datei definieren (Default-Handler)
#DirectoryIndex index.php

# mod_rewrite (sprechende URLs) einschalten
RewriteEngine On
RewriteBase /

# Sicherheitsrelevante Einstellungen
# 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]

# Regel für Umleitung (301) von Anfragen ohne . oder abschließenden /
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_METHOD} !POST$
RewriteRule ^(.*) %{REQUEST_URI}/ [NE,R=301,L]

# Regeln Umleitungen der Seiten-Aliase
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]

# Apache Modul zum Komprimieren der Text-Dateien (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 Modul fürs Cachen von Dateien
<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>

### Voruebergehender Zugriffsschutz ###
#deny from all
#AuthName "Wartungsarbeiten"
#AuthType Basic
#AuthUserFile /path/to/.htpasswd
#require valid-user
#satisfy any

# EOF