# .htaccess for commerce:SEO URL
#
# angepasst von Sebastian Schramm, Daniel Siekiera, Andreas Kausch
# Blog Integration - Daniel Siekiera

AddDefaultCharSet utf-8

# Wenn Sie 1und1 benutzen, setzen Sie die nächsten beiden Zeilen aktiv (Einschalten PHP5)
#AddType x-mapp-php5 .php
#AddHandler x-mapp-php5 .php

# Expire headers 31536000 Sekunden = 1 Jahr
<IfModule mod_expires.c>
	ExpiresActive On
	ExpiresDefault "access plus 31536000 seconds"
	ExpiresByType image/x-icon "access plus 31536000 seconds"
	ExpiresByType image/gif "access plus 31536000 seconds"
	ExpiresByType image/jpg "access plus 31536000 seconds"
	ExpiresByType image/jpeg "access plus 31536000 seconds"
	ExpiresByType image/png "access plus 31536000 seconds"
	ExpiresByType text/css "access plus 31536000 seconds"
	ExpiresByType text/javascript "access plus 31536000 seconds"
	ExpiresByType application/javascript "access plus 31536000 seconds"
	ExpiresByType application/x-javascript "access plus 31536000 seconds"
	ExpiresByType image/ico "access plus 31536000 seconds"
	ExpiresByType text/html "access plus 31536000 seconds"
</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 "\\.(ico)$">
	Header set Cache-Control "max-age=31536000, public"
	</filesmatch>	
</ifmodule>

<ifmodule mod_deflate.c>
<FilesMatch "\\.(js|css|html|htm|php|xml|jpg|jpeg|png|gif)$">
SetOutputFilter DEFLATE
</FilesMatch>
</ifmodule>




<ifmodule mod_gzip.c>
    mod_gzip_on       Yes   
    mod_gzip_dechunk  Yes   
	mod_gzip_minimum_file_size    500
	mod_gzip_maximum_file_size    500000
	mod_gzip_maximum_inmem_size   60000
	mod_gzip_min_http             1000
	mod_gzip_handle_methods        GET POST
	mod_gzip_item_exclude         reqheader  "User-agent: Mozilla/4.0[678]"
    mod_gzip_item_include file      \.(html?|txt|css|js|php|pl)$   
    mod_gzip_item_include handler   ^cgi-script$   
    mod_gzip_item_include mime      ^text/.*   
    mod_gzip_item_include mime      ^application/x-javascript.*   
	mod_gzip_item_include mime       ^text/html$
	mod_gzip_item_include mime       ^text/css$
	mod_gzip_item_include mime       ^text/js$
	mod_gzip_item_include mime       ^image/jpeg$
	mod_gzip_item_include mime       ^image/png$
	mod_gzip_item_include mime       ^image/gif$
	mod_gzip_item_include mime       ^text/plain$
	mod_gzip_item_include mime       ^httpd/unix-directory$	
    mod_gzip_item_exclude mime      ^image/.*   
    mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*   
</ifmodule>

# Turn ETags Off
<ifmodule mod_headers.c>
	Header unset ETag
</ifmodule>
FileETag None

# Zusatzparameter PHP
#php_value max_execution_time 60000
#php_value memory_limit 160M
#php_value arg_separator.output &amp;

# 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
	#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.
	RewriteRule w00tw00t\.at\. - [F,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]

	# 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]

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

	RewriteRule ^(.*)tag/(.*([a-zA-Z0-9]))$						taglisting.php?tag=$1$2 [qsappend,L]
	RewriteRule ^(.*)keywords/(.*([a-zA-Z0-9]))$				advanced_search_result.php?keywords=$1$2 [qsappend,L]
	RewriteRule ^(.*)manufacturer-(.*[0-9])/(.*([a-zA-Z0-9]))$	index.php?manufacturers_id=$2 [qsappend,L]
	RewriteRule ^(.*)review-(.*[0-9])/(.*([a-zA-Z0-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>