Options -Indexes -MultiViews

# Uncomment this line and replace /SUBDIRCTORY/ with your subdirectory if
# you want to show the CMS' not found page in place of Apache's not found page.
#ErrorDocument 404 /SUBDIRCTORY/index.php?cID=~

<ifModule mod_headers.c>
	Header setifempty Content-Security-Policy "default-src *; font-src * data:; img-src * data:; script-src * 'unsafe-eval' 'unsafe-inline'; style-src * 'unsafe-inline'"
	Header setifempty Permissions-Policy "sync-xhr=(self), camera=(), geolocation=(), gyroscope=(), magnetometer=(), midi=(), payment=()"
	Header setifempty Referrer-Policy strict-origin-when-cross-origin
	Header setifempty X-Content-Type-Options nosniff
	Header setifempty X-Frame-Options SAMEORIGIN
	Header setifempty X-XSS-Protection "1; mode=block"
</ifModule>

<IfModule pagespeed_module>
	ModPagespeed off
</IfModule>

<IfModule mod_expires.c>
	AddType application/font-woff .woff
	AddType application/font-woff .woff2
	AddType text/css .css
	AddType text/javascript .js
	AddType image/webp .webp
	
	ExpiresActive On
	ExpiresByType application/font-woff "access plus 1 year"
	ExpiresByType text/css "access plus 1 month"
	ExpiresByType text/javascript "access plus 1 month"
	ExpiresByType image/gif "access plus 1 year"
	ExpiresByType image/jpeg "access plus 1 year"
	ExpiresByType image/png "access plus 1 year"
	ExpiresByType image/webp "access plus 1 year"
	ExpiresByType image/svg+xml "access plus 1 year"
	ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
	ExpiresByType image/x-icon "access plus 1 year"
</IfModule>

<IfModule mod_deflate.c>
	#SetOutputFilter DEFLATE
	AddOutputFilterByType DEFLATE text/css text/csv text/html text/plain text/xml text/javascript application/javascript application/x-javascript
	<IfModule mod_php7.c>
		php_flag zlib.output_compression Off
	</IfModule>
</IfModule>
<IfModule !mod_deflate.c>
	<IfModule mod_php7.c>
		php_flag zlib.output_compression On
	</IfModule>
</IfModule>

<IfModule mod_rewrite.c>
	RewriteEngine On
	
	# Correct any bad relative-URLs
	RewriteRule ^[\/,A-Za-z0-9~_-]*\/(public|private|zenario|zenario_custom|zenario_extra_modules)/(.*)$ zenario/redirect.php?redirectdir=$1&redirect=$2 [L,QSA]
	
	# Redirect anyone trying to access the admin login using "admin/" to just "admin", without the slash.
	# This should not be done silently, we want the visitor to see their URL changing in their browser,
	# so we need to use a PHP script for this.
	RewriteRule ^admin/$ zenario/redirect.php?redirect=admin [L,QSA]
	
	# Admin URL:
	RewriteRule ^admin(|\.\w+)$ zenario/admin/welcome.php [L,QSA]
	RewriteRule ^organizer.php$ zenario/admin/organizer.php [L,QSA]
	
	# Handle most URLs (aliases and spare aliases):
	# Note: regular aliases don't use .doc/.docx/.pdf/.zip, but spare aliases can.
	RewriteCond %{REQUEST_URI} !/(admin|public|private|zenario|zenario_custom|zenario_extra_modules|purchased_downloads)/
	RewriteRule ^([\/,A-Za-z0-9~_-]+)(|\.html|\.htm|\.doc|\.docx|\.pdf|\.zip)$ index.php?cID=$1 [L,QSA]
	
	# Download Now links:
	RewriteRule ^([\/,A-Za-z0-9~_-]+)\.download$ index.php?cID=$1&download=1 [L]
	
	# Staging mode URLs:
	RewriteRule ^staging.php$ zenario/staging.php [L,QSA]
	
	# A friendly URL for the robots.txt file:
	RewriteRule ^robots.txt$ index.php?method_call=robots [L]
	
	# A friendly URL for the XML sitemap:
	RewriteRule ^sitemap.xml$ index.php?method_call=showSitemap [L]
	
	# RSS feeds:
	RewriteRule ^([\/,A-Za-z0-9~_-]+)\.rss$ index.php?cID=$1&method_call=showRSS [L]
	
	# Remove cached pages and stats from public view:
	RewriteRule ^cache/.*$ - [F,NC]

	# Remove the build, backup and docstore directories from public view if they were placed here:
	RewriteRule ^build/.*$ - [F,NC]
	RewriteRule ^backup/.*$ - [F,NC]
	RewriteRule ^docstore/.*$ - [F,NC]
	
	# Remove yaml files and frameworks from public view:
	RewriteRule ^zenario.*\.yaml$ - [F,NC]
	RewriteRule ^zenario_custom/frameworks/.*\.html$ - [F,NC]
	
	# Remove any svn directories from public view:
	RewriteRule \.svn/.*$ - [F,NC]
</IfModule>
