# ----------------------------------------------------------------------
# UTF-8 encoding
# ----------------------------------------------------------------------

# Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset utf-8

# Force UTF-8 for a number of file formats
AddCharset utf-8 .html .css .js .xml .json .rss .atom

# Wenn Sie 1und1 benutzen, setzen Sie die nächsten beiden Zeilen aktiv (Einschalten PHP5.4) Bei 1und1 sollte weiter unten der Punkt RewriteBase / auch auskommentiert werden
#AddHandler x-mapp-php6 .php3 .php4 .php .phtml

# ----------------------------------------------------------------------
# Expires headers (for better cache control)
# ----------------------------------------------------------------------


<IfModule mod_expires.c>
  ExpiresActive on

# Perhaps better to whitelist expires rules? Perhaps.
  ExpiresDefault                          "access plus 1 month"

  ExpiresByType text/cache-manifest       "access plus 0 seconds"
  ExpiresByType text/html                 "access plus 0 seconds"
  ExpiresByType text/xml                  "access plus 0 seconds"
  ExpiresByType application/xml           "access plus 0 seconds"
  ExpiresByType application/json          "access plus 0 seconds"
  ExpiresByType application/rss+xml       "access plus 1 hour"
  ExpiresByType application/atom+xml      "access plus 1 hour"
  ExpiresByType image/x-icon              "access plus 1 week" 
  ExpiresByType image/gif                 "access plus 1 month"
  ExpiresByType image/png                 "access plus 1 month"
  ExpiresByType image/jpg                 "access plus 1 month"
  ExpiresByType image/jpeg                "access plus 1 month"
  ExpiresByType video/ogg                 "access plus 1 month"
  ExpiresByType audio/ogg                 "access plus 1 month"
  ExpiresByType video/mp4                 "access plus 1 month"
  ExpiresByType video/webm                "access plus 1 month"
  ExpiresByType text/x-component          "access plus 1 month"
  ExpiresByType font/truetype             "access plus 1 month"
  ExpiresByType font/opentype             "access plus 1 month"
  ExpiresByType application/x-font-woff   "access plus 1 month"
  ExpiresByType image/svg+xml             "access plus 1 month"
  ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
  ExpiresByType text/css                  "access plus 1 year"
  ExpiresByType application/javascript    "access plus 1 year"
  ExpiresByType application/x-javascript  "access plus 1 year"

  
  <IfModule mod_headers.c>
    Header append Cache-Control "public"
  </IfModule>
  
</IfModule>

# BEGIN Cache-Control Headers
<ifmodule mod_headers.c>
	<filesmatch "\\.(ico|jpe?g|png|gif|swf)$">
		Header set Cache-Control "max-age=31536000, public"
	</filesmatch>
	<filesmatch "\\.(css)$">
		Header set Cache-Control "max-age=31536000, public"
	</filesmatch>
	<filesmatch "\\.(js)$">
		Header set Cache-Control "max-age=31536000, public"
	</filesmatch>
	<filesmatch "\\.(jgz)$">
		Header set Cache-Control "max-age=31536000, public"
	</filesmatch>
	<filesmatch "\\.(ico)$">
		Header set Cache-Control "max-age=31536000, public"
	</filesmatch>	
	<filesmatch "\\.(html)$">
		Header set Cache-Control "max-age=31536000, public"
	</filesmatch>
	Header unset ETag
	<filesmatch "\.(js|css|xml|gz|jgz)$">
		Header append Vary: Accept-Encoding
	</filesmatch>
</ifmodule>

<ifmodule mod_deflate.c>
<filesmatch "\\.(js|css|html|htm|php|xml)$">
SetOutputFilter DEFLATE
</filesmatch>
</ifmodule>

# ----------------------------------------------------------------------
# Gzip compression
# ----------------------------------------------------------------------

<IfModule mod_deflate.c>

# Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
<IfModule mod_setenvif.c>
  <IfModule mod_headers.c>
    SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
    RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
  </IfModule>
</IfModule>
</IfModule>

# HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
<IfModule filter_module>
  FilterDeclare   COMPRESS
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/html
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/css
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/plain
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/xml
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/x-component
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/javascript
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/json
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/xml
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/xhtml+xml
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/rss+xml
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/atom+xml
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/vnd.ms-fontobject
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $image/svg+xml
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/x-font-ttf
  FilterProvider  COMPRESS  DEFLATE resp=Content-Type $font/opentype
  FilterChain     COMPRESS
  FilterProtocol  COMPRESS  DEFLATE change=yes;byteranges=no
</IfModule>


# ----------------------------------------------------------------------
# ETag removal
# ----------------------------------------------------------------------

#   developer.yahoo.com/performance/rules.html#etags
FileETag None

# Zusatzparameter PHP
#php_flag zlib.output_compression On

# Dateiauflisting unterbinden
Options -Indexes

# Kommentieren Sie diese Zeile aus, wenn Sie einen Fehler 500 (Internal Server Error) erhalten
#Options +FollowSymlinks

<IfModule mod_rewrite.c>
	RewriteEngine On
	# Bilder durch jagen
	#RewriteCond %{REQUEST_URI} !assets
	#RewriteCond %{REQUEST_URI} !ai-cache
	#RewriteRule \.(?:jpe?g|gif|png)$ adaptive-images.php

	# Javascripte gezip ausliefern
	
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.jgz -f
RewriteRule (.*)\.js$ $1\.js.jgz [L]
AddType "text/javascript" .js.jgz
AddEncoding gzip .jgz
	
	#Sicherheit
	## Begin - Rewrite rules to block out some common exploits.
	# If you experience problems on your site block out the operations listed below
	# Block out any script trying to base64_encode data within the URL.
	RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
	# Block out any script that includes a <script> tag in URL.
	RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
	# Block out any script trying to set a PHP GLOBALS variable via URL.
	RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
	# Block out any script trying to modify a _REQUEST variable via URL.
	RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
	# Return 403 Forbidden header and show the content of the root homepage
	RewriteRule .* index.php [F]
	#
	## End - Rewrite rules to block out some common exploits.
	# Port Scanner
	RewriteCond %{HTTP_USER_AGENT} 					^w00tw00t.at.ISC.SANS.DFind
	RewriteRule ^.*$ 								403.php [L]
	
	# sitemap.xml auf Dynamische umleiten
	RewriteRule ^(.*)sitemap.xml$					sitemap.xml.php [qsappend,L]
	

	Options +SymLinksIfOwnerMatch

	# Umleitung auf Adresse mit www, wenn www fehlt und nicht Subdomain und nicht localhost und nicht ssl.webpack.de
	RewriteCond %{HTTP:X-Forwarded-Server} 	!^ssl\.webpack\.de$ [NC]
	RewriteCond %{HTTP:X-Forwarded-Server} 	!^sslsites\.de$ [NC]
	RewriteCond %{HTTP_HOST}   				!^www\..* [NC]
	RewriteCond %{HTTP_HOST}   				!^.*\..*\..* [NC]
	RewriteCond %{HTTP_HOST}   				!^localhost(.*)$ [NC]
	RewriteRule ^(.*)          				http://www.%{HTTP_HOST}/$1 [R=301,L]
	
	
	###################################################################################################
	########	Shopstat - URL Format --- by Webdesign Erfurt
	########
	
	##-- Kategorien
	RewriteCond %{REQUEST_URI} 								(.*)---([_0-9]+)-([_0-9]+)\.html$
	RewriteRule (.*)---([_0-9]+)-([_0-9]+)\.html$ 			index.php?cPath=$2&page=$3 [qsappend,L]
	
	RewriteCond %{REQUEST_URI} 								(.*)---([_0-9]+)\.html$
	RewriteRule (.*)---([_0-9]+)\.html$ 					index.php?cPath=$2 [qsappend,L]

	##-- Produkte
	RewriteRule (.*)--(.+)\.html$ 							product_info.php?products_id=$2 [qsappend,L]

	##-- Content
	RewriteRule (.*)-_-([0-9]+)\.html$ 						shop_content.php?coID=$2 [qsappend,L]

	########
	########
	####################################################################################################
	
	
	###################################################################################################
	########	Shopstat - URL Format ::: by Shopstat
	########
	
	##-- Kategorien
	RewriteCond %{REQUEST_URI} 								(.*):::([_0-9]+)-([_0-9]+)\.html$
	RewriteRule (.*):::([_0-9]+)-([_0-9]+)\.html$ 			index.php?cPath=$2&page=$3 [qsappend,L]
	
	RewriteCond %{REQUEST_URI} 								(.*):::([_0-9]+)\.html$
	RewriteRule (.*):::([_0-9]+)\.html$ 					index.php?cPath=$2 [qsappend,L]

	##-- Produkte
	RewriteRule (.*)::(.+)\.html$ 							product_info.php?products_id=$2 [qsappend,L]

	##-- Content
	RewriteRule (.*):_:([0-9]+)\.html$ 						shop_content.php?coID=$2 [qsappend,L]

	########
	########
	####################################################################################################
	

	# immer auf den root verweisen, damit die Startseite (/index.php) nicht zweimal vorkommt
	# die folgenden beiden Zeilen auskommentieren wenn Sie eine index.html nutzen wollen
	RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(html?|php)\ HTTP/
	RewriteRule ^index\.(html?|php)$ http://%{HTTP_HOST}/ [R=301,L]

	# Editieren Sie die untenstehende Zeile wenn ihr Shop in einem Unterordner läuft.
	# Aber auch wenn Sie einen Fehler 500 (Internal Server Error) bekommen.
	# Beispiel: Ist ihr Shop im Verzeichnis www.domain.de/shop ändern Sie die Zeile wie folgt: "RewriteBase /shop/"
	#RewriteBase /

	RewriteCond %{REQUEST_FILENAME} -f [OR]
	RewriteCond %{REQUEST_FILENAME} -d

	RewriteRule ^(.+) - [PT,L]
	
	# Alte Kategorien ohne Slash umleiten auf mit slash / Raute in den 4 Zeilen entfernen
	#RewriteCond %{REQUEST_URI} !(.*)/$
	#RewriteCond %{REQUEST_URI} !\..+$
	#RewriteCond %{REQUEST_URI} !/$
	#RewriteRule (.*) http://%{HTTP_HOST}/$1/ [R=301,L]

	RewriteRule ^(.*)(.+)404.php$								404.php [qsappend,L]

	RewriteRule ^(.*)tag/(.*([a-zßöüäA-ZÖÜÄ0-9]))/$ taglisting.php?tag=$1$2 [qsappend,L]
	RewriteRule ^(.*)hashtag/(.*([a-zßöüäA-ZÖÜÄ0-9]))$		hashtags.php?hashtags=$1$2 [qsappend,L]
	RewriteRule ^(.*)keywords/(.*([a-zßöüäA-ZÖÜÄ0-9]))$		advanced_search_result.php?keywords=$1$2 [qsappend,L]
	RewriteRule ^(.*)manufacturer-(.*[0-9])/(.*([a-zßöüäA-ZÖÜÄ0-9]))$	index.php?manufacturers_id=$2 [qsappend,L]
	RewriteRule ^(.*)review-(.*[0-9])/(.*([a-zßöüäA-ZÖÜÄ0-9]))$		product_reviews_info.php?reviews_id=$2 [qsappend,L]

	#RewriteRule ^(.*)(.+)\.html(.*)$ 							commerce_seo_url.php?linkurl=$1$2$3 [qsappend,L]

	RewriteCond %{REQUEST_FILENAME} !\.html$ [OR]
	RewriteCond %{REQUEST_FILENAME} !\.php$ [OR]
	RewriteRule ^(.*)$											commerce_seo_url.php?linkurl=$1 [qsappend,L]
</IfModule>


ErrorDocument 404 /404.php
ErrorDocument 403 /403.php