# Set index.n to come before index.php

DirectoryIndex index.n index.php index.html

RewriteEngine On

# /files are stored in S3

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{ENV:HAXELIB_S3BUCKET} !^$
RewriteCond %{ENV:AWS_DEFAULT_REGION} !^$
RewriteRule "^files/(.*)$" "http://%{ENV:HAXELIB_S3BUCKET}.s3-%{ENV:AWS_DEFAULT_REGION}.amazonaws.com/files/$1" [P]

# Rewrite rules to send Haxe remoting calls on "/" to "haxelib1/".  If it matches, that's [L], the last rule - go their immediately.

RewriteBase /
RewriteCond %{HTTP:X-Haxe-Remoting}: 1
RewriteRule ^index.n$ legacy/index.n [L]

# Enable rewrite for the new site's pages, only if the file or dir doesn't exist

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.n/$1 [L]

# Get our stuff gzipped

SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript