# GETAWAY on Afrihost — added for the server only (the local PHP dev server ignores this file).
Options -Indexes
DirectoryIndex index.php index.html

# SECURITY — no answer names the PHP version (the PHP pages remove it too; this covers anything that does not load them)
<IfModule mod_headers.c>
Header always unset X-Powered-By
Header unset X-Powered-By
</IfModule>

RewriteEngine On

# SECURITY — whatever someone asks for, these are never served: database, backup, log, key and SQL files, and any file or folder whose name starts with a
# dot (except .well-known, which the certificate check needs).
RewriteRule (^|/)\.(?!well-known(/|$)) - [F,L]
RewriteRule \.(sqlite3?|db|bak|sql|key|log|swp|orig|env|lock|md|zip|ps1|sh)$ - [F,L,NC]
# SECURITY — the local development router is never run on the live server
RewriteRule ^router\.php$ - [F,L,NC]
# SECURITY — uploaded pictures are never run as programs, even if a file with a program's name got into the folder.
RewriteRule ^uploads/.+\.(php[0-9]*|phtml|phar|pl|py|cgi|sh|shtml)$ - [F,L,NC]

# Send http:// to https://, but let AutoSSL verify the domain over plain http.
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/\.well-known/
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

<IfModule mod_rewrite.c>
# Corporate clients on their own domain (pointed at this server): the whole domain is their booker.
# The file getaway/corporate/domains/<domain> is written by the back office (Corporate → client → Access → Their own domain).
RewriteCond %{REQUEST_URI} !^/\.well-known/
RewriteCond %{DOCUMENT_ROOT}/../corporate/domains/%{HTTP_HOST} -f
RewriteRule ^ corporate/index.php [L,QSA]

# Corporate clients at https://<this site>/<client>/ — each in its own folder getaway/corporate/clients/<client>/ (like the showcase sites).
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/([a-z0-9-]{2,40})(/|$)
RewriteCond %{DOCUMENT_ROOT}/../corporate/clients/%1/config.php -f
RewriteRule ^ corporate/index.php [L,QSA]

# Showcase gate: the design sites are only served to signed-in visitors (public/gate.php)
RewriteCond %{REQUEST_URI} ^/(travel5a|travel(?!5(/|$))[0-9]*(-v2)?|buffelsfontein[0-9]?|helloboet(_widget)?[0-9]?)(/|$)
RewriteRule ^ gate.php [L]
</IfModule>
