<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
    Header set Content-Security-Policy "frame-ancestors 'self' https://*.ashampoo.com https://*.cms.test"
</IfModule>

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?ashampoo\.com$ [NC]
RewriteCond %{REQUEST_URI} !^(.+)(\.(exe|apk|pkg|dmg|iso|msi|zip|pdf)|downloads\.php) [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTP_HOST} ^ashampoo\.com$ [NC]
RewriteRule (.*) https://www.ashampoo.com%{REQUEST_URI} [R=301,L]

RedirectMatch /extern/(.*) https://img.ashampoo.com/ashampoo.com_images/$1

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# ashampoo domains
RewriteCond %{HTTP_HOST} ^(cfwww\.|www\.)?ashampoo\.(de|us|co\.uk|hu|net|eu|org|biz|info|mobi)$ [NC]
RewriteRule ^(.*)$    https://www.ashampoo.com [L,R=301]

RedirectMatch ^/media/([^/]+)/?         /loc/media/$1
RedirectMatch ^/lpa/([^/]+)/([^/]+)/?   /loc/lpa/$1/$2
RedirectMatch ^/lpa/([^/]+)/?           /loc/lpa/$1

# temporary redirects
RedirectMatch ^/([a-z]{2}-[a-z]{2})/mpl/?$                      /$1/password-lost
RedirectMatch ^/([a-z]{2}-[a-z]{2})/moorhuhn/?$                 /$1/campaigns/moorhuhn

# campaigns
RedirectMatch ^/([a-z]{2}-[a-z]{2})/bsc/cp                       /$1/campaigns/cleverpush

# disable eastereggs
RewriteCond %{QUERY_STRING} \=PHP[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12} [NC]
RewriteRule .* - [F]

# dialog bant, dirs exists, so new routing does not work
RewriteRule ^dialog-bant/([^/]+)/?$     /index.php [L,NC,QSA]

# route everything else through frontend routing
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !=/server-status
RewriteRule ^ /index.php [L,NC,QSA]