# ----------------------------------------------------------------------
# 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 .atom .css .js .json .rss .vtt .xml

# ----------------------------------------------------------------------
# Some Security
# ----------------------------------------------------------------------

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
SetEnvIfNoCase User-Agent "^libwww-perl*" block_bad_bots
Deny from env=block_bad_bots

<Limit GET POST>
	order deny,allow
	deny from all
	allow from all
</Limit>

<Limit PUT DELETE>
	order deny,allow
	deny from all
</Limit>

# Prevent Folder's browsing
<IfModule mod_autoindex.c>
    Options -Indexes
</IfModule>

# Block access to "hidden" directories or files
<IfModule mod_rewrite.c>
    RewriteCond %{SCRIPT_FILENAME} -d [OR]
    RewriteCond %{SCRIPT_FILENAME} -f
    RewriteRule "(^|/)\." - [F]
</IfModule>

# Block access to backup and source files.
<FilesMatch "(\.(bak|config|dist|fla|inc|ini|log|psd|sh|sql|swp)|~)$">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>

# Increase cookie security
<IfModule mod_php5.c>
    php_value session.cookie_httponly true
</IfModule>

# Disable server signature
ServerSignature Off

# ----------------------------------------------------------------------
# Make the index handle all Request's
# ----------------------------------------------------------------------

<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteBase /
	RewriteCond %{REQUEST_URI} ^system.*
	RewriteRule ^(.*)$ /index.html?/$1 [L]
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule ^(.*)$ index.html?/$1 [L]
</IfModule>

# ----------------------------------------------------------------------
# Error Documents
# ----------------------------------------------------------------------
ErrorDocument 400 /engine/error/400.html
ErrorDocument 401 /engine/error/401.html
ErrorDocument 403 /engine/error/403.html
ErrorDocument 404 /engine/error/404.html
ErrorDocument 405 /engine/error/405.html
ErrorDocument 408 /engine/error/408.html
ErrorDocument 429 /engine/error/429.html
ErrorDocument 500 /engine/error/500.html
ErrorDocument 503 /engine/error/503.html

# ----------------------------------------------------------------------
# Enable Gzip
# ----------------------------------------------------------------------
<ifModule mod_gzip.c>
	mod_gzip_on Yes
	mod_gzip_dechunk Yes
	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_exclude mime ^image/.*
	mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>