# api/.htaccess             - Old Api
# servicedesk/.htaccess     - Service Desk App

# conf/.htaccess            - Deny definition
# ext/composert/.htaccess   - Deny definition
# images/.htaccess          - Allow definition

Options +FollowSymLinks

RewriteEngine On
RewriteBase /

# Static
RewriteRule ^co/images/([^/]+)$     /images/$1 [L]
RewriteRule ^cache/images/([^/]+)$  /images/$1 [L]
RewriteRule ^img/([^/]+)$           /images/$1 [L]
RewriteRule ^pm/_images/([^/]+)$    /images/$1 [L]
RewriteRule ^pm/images/([^/]+)$     /images/$1 [L]
RewriteRule ^favicon(.*)$           /images/favicon$1 [L]

# Redirects
RewriteRule ^co/login\.php$                 /login              [R=301,L]
RewriteRule ^co/projects\.php$              /                   [R=301,L]
RewriteRule ^co/projects$                   /                   [R=301,L]
RewriteRule ^co//?$                         /                   [R=301,L]
RewriteRule ^projects$                      /                   [R=301,L]
RewriteRule ^app/servicedesk\.php(/(.*)|$)  /servicedesk/$2     [R=301,L]

# Backward compatibility App Entry points
RewriteCond %{REQUEST_URI} /join-project [OR]
RewriteCond %{REQUEST_URI} /plugins [OR]
RewriteCond %{REQUEST_URI} /login [OR]
RewriteCond %{REQUEST_URI} /recovery [OR]
RewriteCond %{REQUEST_URI} /reset [OR]
RewriteCond %{REQUEST_URI} /404 [OR]
RewriteCond %{REQUEST_URI} /50[\d]{1} [OR]
RewriteCond %{REQUEST_URI} /cache [OR]
RewriteCond %{REQUEST_URI} /scripts [OR]
RewriteCond %{REQUEST_URI} /images [OR]
RewriteCond %{REQUEST_URI} /img [OR]
RewriteCond %{REQUEST_URI} /favicon [OR]
RewriteCond %{REQUEST_URI} /tasks
RewriteCond %{REQUEST_URI} !^/app/app\.php
RewriteCond %{REQUEST_URI} !^/app/non-auth\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /app/non-auth.php [L]

# App Entry points
RewriteCond %{REQUEST_URI} !^/server-status
RewriteCond %{REQUEST_URI} !^/app/app\.php
RewriteCond %{REQUEST_URI} !^/app/non-auth\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /app/app.php [L]
