#********************************************************************************************************
#   (c) 2004-2006 by MulchProductions, www.mulchprod.de                                                 *
#   (c) 2007-2013 by Kajona, www.kajona.de                                                              *
#       Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt                                 *
#-------------------------------------------------------------------------------------------------------*
#	$Id: .htaccess.root 5409 2012-12-30 13:09:07Z sidler $                                                   *
#*******************************************************************************************************/

######################################## GENERAL URL REWRITING ############################################

# if you want to use mod_rewrite for nice-urls, set RewriteEngine on and enable all following RewriteRules.
# Please note to enable URL-Rewriting in Kajona's system-settings, too!
#Options -Multiviews
#RewriteEngine on


# enable only in case of errors
#RewriteBase /

# enable these two lines and insert your domain to prevent duplicate content in search engines (SEO)
# but don't enable on your local machine - otherwise you'll always be redirected to the live server
#RewriteCond %{HTTP_HOST} !^www.yourdomain.com$ [NC]
#RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]

# Enable rewrite rules for html and rss suffixes as well as for requests containing xml/admin, but skip
# rewriting for .js files
#RewriteRule (!\.html|!\.rss|!xml/admin(.*)|\.js)$ - [L]


######################################## ADMIN REWRITING ##################################################

# xml rewriting. source: /xml/admin/module/action/systemid/
#RewriteRule !^xml/admin/ - [S=3]
#RewriteRule ^xml/admin/([a-z\_]+)/([a-zA-Z]*)/([0-9a-z]*) xml.php?admin=1&module=$1&action=$2&systemid=$3 [QSA,L]
#RewriteRule ^xml/admin/([a-z\_]+)/([a-zA-Z]*)  xml.php?admin=1&module=$1&action=$2 [QSA,L]
#RewriteRule ^xml/admin/([a-z\_]+)  xml.php?admin=1&module=$1 [QSA,L]

# source: /admin/module/action/systemid
#RewriteRule !^admin/  - [S=4]
#RewriteRule ^admin/index.html index.php?admin=1
#RewriteRule ^admin/([a-z\_]+)/([a-zA-Z]*)/([0-9a-z]*)\.html  index.php?admin=1&module=$1&action=$2&systemid=$3 [QSA,L]
#RewriteRule ^admin/([a-z\_]+)/([a-zA-Z]*)\.html  index.php?admin=1&module=$1&action=$2 [QSA,L]
#RewriteRule ^admin/([a-z\_]+)\.html  index.php?admin=1&module=$1 [QSA,L]


######################################## PORTAL REWRITING #################################################

# source: page.seo.action.systemid.language
# Only required for backward compatibility
#RewriteRule ^(.*?/)?([0-9a-z\_\-]+)\.(.*)\.([a-zA-Z]*)\.([0-9a-z]*)\.([a-z]{2})\.html  index.php?page=$2&action=$4&systemid=$5&language=$6 [QSA,L]

# source: language/page.seo.action.systemid
#RewriteRule ^(([a-z]{2})/)(.*/)?([0-9a-z\_\-]+)\.(.*)\.([a-zA-Z]*)\.([0-9a-z]*)\.([a-z]{2})\.html  index.php?page=$4&action=$6&systemid=$7&language=$2 [QSA,L]

# source: page.seo.action.systemid
#RewriteRule ^(.*/)?([0-9a-z\_\-]+)\.(.*)\.([a-zA-Z]*)\.([0-9a-z]*)\.html  index.php?page=$2&action=$4&systemid=$5 [QSA,L]

# source: language/page.seo.action
#RewriteRule ^(([a-z]{2})/)(.*/)?([0-9a-z\_\-]+)\.(.*)\.([a-zA-Z]*)\.html  index.php?page=$4&action=$6&language=$2 [QSA,L]

# source: page.seo.action
#RewriteRule ^(.*/)?([0-9a-z\_\-]+)\.(.*)\.([a-zA-Z]*)\.html  index.php?page=$2&action=$4 [QSA,L]

# source: page.language
# Only required for backward compatibility
#RewriteRule ^(.*?/)?([0-9a-z\_\-]+)\.([a-z]{2})\.html  index.php?page=$2&language=$3 [QSA,L]

# source: language/page[.seo]
#RewriteRule ^(([a-z]{2})/)(.*/)?([0-9a-z\_\-]+)(\.(.*))?\.html  index.php?page=$4&language=$2 [QSA,L]

# source: page[.seo]
#RewriteRule ^(.*/)?([0-9a-z\_\-]+)(\.(.*))?\.html  index.php?page=$2 [QSA,L]

# rss-feeds
#RewriteRule ^([0-9a-z\_\-]+)\.rss  xml.php?module=news&action=newsFeed&feedTitle=$1 [L]


######################################## PHP ##############################################################

# The following directives can be used to configure php directly,
# enable them with care and just in case of problems
#php_value post_max_size 16M
#php_value upload_max_filesize 16M
#php_value memory_limit 32M

# If your webserver attaches the PHPSESSID to links generated by the system, enable the following directive
#php_value session.use_trans_sid 0

# In some cases, the flash-upload failes if use_conly_cookies is set to 1
#php_value session.use_only_cookies 0


######################################## SECURITY/DEBUG ###################################################

# recommended: enable the following lines to prevent displaying php errors in browser and instead log php errors into file
#php_value display_errors Off
#php_value log_errors On
#php_value error_log project/log/php.log


######################################## PERFORMANCE ######################################################
# borrowed from HTML5 Boilerplate; http://html5boilerplate.com/

# Proper mime types

# JavaScript
#   Normalize to standard type (it's sniffed in IE anyways)
#   tools.ietf.org/html/rfc4329#section-7.2
AddType application/javascript         js jsonp
AddType application/json               json

# Audio
AddType audio/ogg                      oga ogg
AddType audio/mp4                      m4a f4a f4b

# Video
AddType video/ogg                      ogv
AddType video/mp4                      mp4 m4v f4v f4p
AddType video/webm                     webm
AddType video/x-flv                    flv

# SVG
#   Required for svg webfonts on iPad
#   twitter.com/FontSquirrel/status/14855840545
AddType     image/svg+xml              svg svgz
AddEncoding gzip                       svgz

# Webfonts
AddType application/vnd.ms-fontobject  eot
AddType application/x-font-ttf         ttf ttc
AddType font/opentype                  otf
AddType application/x-font-woff        woff

# Assorted types
AddType image/x-icon                        ico
AddType image/webp                          webp
AddType application/xml                     rss atom xml rdf
AddType application/x-chrome-extension      crx
AddType application/x-opera-extension       oex
AddType application/x-xpinstall             xpi
AddType application/octet-stream            safariextz
AddType application/x-web-app-manifest+json webapp
AddType text/x-vcard                        vcf
AddType application/x-shockwave-flash       swf
AddType text/vtt                            vtt

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

  # Compress all output labeled with one of the following MIME-types
  <IfModule mod_filter.c>
    AddOutputFilterByType DEFLATE application/atom+xml \
                                  application/javascript \
                                  application/json \
                                  application/rss+xml \
                                  application/vnd.ms-fontobject \
                                  application/x-font-ttf \
                                  application/xhtml+xml \
                                  application/xml \
                                  font/opentype \
                                  image/svg+xml \
                                  image/x-icon \
                                  text/css \
                                  text/html \
                                  text/plain \
                                  text/x-component \
                                  text/xml
  </IfModule>
</IfModule>

# Expires headers (for better cache control)

<IfModule mod_expires.c>
  ExpiresActive on

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

# Your document html
  ExpiresByType text/html                 "access plus 0 seconds"

# Data
  ExpiresByType text/xml                  "access plus 0 seconds"
  ExpiresByType application/xml           "access plus 0 seconds"
  ExpiresByType application/json          "access plus 0 seconds"

# Feed
  ExpiresByType application/rss+xml       "access plus 1 hour"
  ExpiresByType application/atom+xml      "access plus 1 hour"

# Favicon (cannot be renamed)
  ExpiresByType image/x-icon              "access plus 1 week"

# Media: images, video, audio
  ExpiresByType image/gif                 "access plus 1 day"
  ExpiresByType image/png                 "access plus 1 day"
  ExpiresByType image/jpeg                "access plus 1 day"
  ExpiresByType video/ogg                 "access plus 1 day"
  ExpiresByType audio/ogg                 "access plus 1 day"
  ExpiresByType video/mp4                 "access plus 1 day"
  ExpiresByType video/webm                "access plus 1 day"

# Webfonts
  ExpiresByType application/x-font-ttf    "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"

# CSS and JavaScript
  ExpiresByType text/css                  "access plus 1 day"
  ExpiresByType application/javascript    "access plus 1 day"
</IfModule>
