RewriteEngine on

# ========================================================================
# PDF-Specific Redirects - Fixed for URL-encoded characters
# ========================================================================
# Handle PDF redirects with path transformation
# Old: /Files/Images/kronospan/Download/[path]/file.pdf
# New: https://kronospan.com/public/files/static-pages-content/dk/krono-dk/[path]/file.pdf
# 
# IMPORTANT: These rules now properly handle URL-encoded characters like %20 (space) and %C3%85 (Å)

# For kronospan-dk.dk.kronospan-express.com domain
RewriteCond %{HTTP_HOST} ^kronospan\-dk\.dk\.kronospan\-express\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.kronospan\-dk\.dk\.kronospan\-express\.com$
RewriteCond %{REQUEST_URI} ^/Files/Images/kronospan/Download/.+\.pdf$ [NC]
RewriteRule ^Files/Images/kronospan/Download/(.+)$ https://kronospan.com/public/files/static-pages-content/dk/krono-dk/$1 [R=301,L,NE]

# For kronospan-dk.dk domain
RewriteCond %{HTTP_HOST} ^kronospan\-dk\.dk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.kronospan\-dk\.dk$
RewriteCond %{REQUEST_URI} ^/Files/Images/kronospan/Download/.+\.pdf$ [NC]
RewriteRule ^Files/Images/kronospan/Download/(.+)$ https://kronospan.com/public/files/static-pages-content/dk/krono-dk/$1 [R=301,L,NE]

# ========================================================================
# Homepage and General Page Redirects
# ========================================================================
# These catch-all rules handle all non-PDF requests

RewriteCond %{HTTP_HOST} ^kronospan\-dk\.dk\.kronospan\-express\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.kronospan\-dk\.dk\.kronospan\-express\.com$
RewriteRule ^/?$ "https://kronospan.com/en_DK/" [R=301,L]

RewriteCond %{HTTP_HOST} ^kronospan\-dk\.dk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.kronospan\-dk\.dk$
RewriteRule ^(.*)$ "https://kronospan.com/en_DK/$1" [R=301,L]

# ========================================================================
# PHP Handler - cPanel Generated
# ========================================================================

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php82” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php82 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
