# Copyright (c) 2013, webvariants GbR, http://www.webvariants.de
#
# This file is released under the terms of the MIT license. You can find the
# complete text in the attached LICENSE file or online at:
#
# http://www.opensource.org/licenses/mit-license.php

RewriteEngine On
# RewriteBase /

# Don't allow access to certain files
<FilesMatch "^((composer\.(json|lock))|version|LICENSE)$">
	Deny from all
</FilesMatch>

# Single-Domain
# RewriteCond %{HTTP_HOST} ^example\.de$
# RewriteRule ^(.*)$ http://www.example.de/$1 [R=301,L]

# Sally Legacy Backend
RewriteRule ^backend/assets/(.*?)$ sally/backend/assets/$1 [L]
RewriteRule ^backend/?$            index.php [QSA,E=SLYAPP:backend]
RewriteRule ^backend/(.*)$         index.php [QSA,E=SLYAPP:backend]

# Sally Setup
RewriteRule ^setup/assets/(.*?)$ sally/setup/assets/$1 [L]
RewriteRule ^setup/?$            index.php [QSA,E=SLYAPP:setup]
RewriteRule ^setup/(.*)$         index.php [QSA,E=SLYAPP:setup]

# Image Resize
RewriteRule ^imageresize/(.+)$ data/mediapool/$1 [L]

# Deployer
RewriteRule ^assets/([^/]+)/deployer\.([a-f0-9]+)\.min\.(css|js|less)$ data/dyn/public/webvariants/deployer/compressed_$2.$3

# Assets Cache
RewriteCond %{REQUEST_FILENAME}  \.(less|css|js|gif|jpg|jpeg|png|swf|ico|pdf|webp)$
RewriteCond %{REQUEST_URI}       !wym_styles.css$
RewriteRule ^(.*)$               data/dyn/public/sally/static-cache/$1 [L]

RewriteCond %{REQUEST_FILENAME}  !-f
RewriteCond %{REQUEST_FILENAME}  !-d
RewriteCond %{REQUEST_FILENAME}  !-l
RewriteCond %{REQUEST_URI}       !^assets/.*
RewriteCond %{REQUEST_URI}       !^data/.*
RewriteCond %{REQUEST_URI}       !^sally/.*
RewriteRule .*                   index.php [E=SLYAPP:frontend,E=SLYBASE:/]
