# BEAM WebService Settings

# For 1and1
#AddType x-mapp-php6 .php

# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
  Order allow,deny
</FilesMatch>

# Add Python support
#AddHandler cgi-script py

# Add perl support
#AddHandler cgi-script py pl
#Options +ExecCGI

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

#Script PUT put.php

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Customized error messages.
ErrorDocument 404 /index.php

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in config.php
# but the following cannot be changed at runtime.

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
  php_value upload_max_filesize             "250M"
  php_value post_max_size                   "500M"
</IfModule>

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  ExpiresActive On

  # Default 1 week
#  ExpiresDefault A604800

  # Cache images for 1 week
  ExpiresByType image/jpg "access 1 week"
  ExpiresByType image/jpeg "access 1 week"
  ExpiresByType image/gif "access 1 week"
  ExpiresByType image/png "access 1 week"
  ExpiresByType image/x-icon "access 1 week"
  ExpiresByType application/pdf "access 1 week"
	
  # Cache javascript and CSS for 1 week
  #ExpiresByType application/x-javascript "access 1 day"
  #ExpiresByType text/css "access 1 day"

  <FilesMatch "^.*files.*$">
    ExpiresByType image/jpg "access 1 minute"
    ExpiresByType image/jpeg "access 1 minute"
  </FilesMatch>

  # HTML 1mins
#  ExpiresByType text/html A2
</IfModule>


# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on
# RewriteBase /

  # PHP (CGI mode) HTTP Authorization with ModRewrite:
  RewriteCond %{HTTP:Authorization} ^(.*)
  RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]

  # Only allow main index.php to run
  RedirectMatch 403 /.*/index.php

  # If files exist under /files use them
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{DOCUMENT_ROOT}/files/%{REQUEST_URI} -f
  RewriteRule ^(.*\.css)$		files/$1 [L,NC]
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{DOCUMENT_ROOT}/files/%{REQUEST_URI} -f
  RewriteRule ^(.*\.js)$		files/$1 [L,NC]

# Allow direct access to some things so themes,javascript and caching works efficiently
  RewriteCond %{REQUEST_FILENAME} -f
  RewriteRule ^(.*\.css)$		$1 [L,NC]
  RewriteCond %{REQUEST_FILENAME} -f
  RewriteRule ^(.*\.js)$		$1 [L,NC]
  RewriteCond %{REQUEST_FILENAME} -f
  RewriteRule ^(.*\.java)$		$1 [L,NC]

  RewriteRule ^(modules/.*\.png)$	$1 [L,NC]

# Allow direct access to old /files path for pictures only for caching
  RewriteRule ^(files/.*\.jpg)$		$1 [L,NC]
  RewriteRule ^(files/.*\.jpeg)$	$1 [L,NC]
  RewriteRule ^(files/.*\.png)$		$1 [L,NC]
  RewriteRule ^(files/.*\.gif)$		$1 [L,NC]
  #RewriteRule ^(files/.*\.mp3)$		$1 [L,NC]
  #RewriteRule ^(files/.*\.mp4)$		$1 [L,NC]
  RewriteRule ^(themes/.*\.png)$	$1 [L,NC]
  RewriteRule ^(themes/.*\.gif)$	$1 [L,NC]
  RewriteRule ^(icons/.*\.gif)$		$1 [L,NC]
  RewriteRule ^(icons/.*\.png)$		$1 [L,NC]
  RewriteRule ^(icons/.*\.jpg)$		$1 [L,NC]
  RewriteRule ^(icons/.*\.svg)$		$1 [L,NC]
  RewriteRule ^(themes/.*\.gif)$	$1 [L,NC]
  RewriteRule ^(themes/.*\.png)$	$1 [L,NC]
  RewriteRule ^(themes/.*\.jpg)$	$1 [L,NC]
  RewriteRule ^(themes/.*\.svg)$	$1 [L,NC]
  RewriteRule ^(lib/.*\.gif)$		$1 [L,NC]
  RewriteRule ^(lib/.*\.png)$		$1 [L,NC]
  RewriteRule ^(lib/.*\.php)$		$1 [L,NC]
  RewriteRule ^(lib/java/.*\.jar)$	$1 [L,NC]
  #RewriteRule ^(.*\.php)$		$1 [L,NC]

# Allow some specials
#  RewriteRule ^(files/public_html/RedirectIt.php)$		$1 [L,QSA]
#  RewriteRule ^(RedirectIt.php)$		$1 [L,QSA]

# Tests
#RewriteRule ^(files/public_html/cgi-bin/.*\.pl)$		$1 [L,QSA]
#RewriteRule ^(files/public_html/cgi-bin/.*)$			$1 [L,QSA]
#RewriteRule ^(files/public_html/cgi-bin/*)$		$1 [L,QSA]
#RewriteRule ^(files/public_html/cgi-bin/.*\.txt)$		$1 [L,QSA]
#RewriteRule ^(test/.*)$					$1 [L,QSA]

# All other URL's through index.php
RewriteRule ^(.*)$			index.php [L,QSA]
</IfModule>
