ErrorDocument 404 /index.php?page=404 # Redirect old URLs to new ones RewriteCond &%{QUERY_STRING} &lang=(cs|en|de) [NC] RewriteCond %1@&%{QUERY_STRING} (cs|en|de)@.*&page=([^&]+) [NC] RewriteRule ^((index|mainkrk|print)\.php)?(\?.*)?$ /krk/%1/%2.html [R=301,QSD,L,nosubreq] RewriteCond &%{QUERY_STRING} &page=([^&]+) [NC] RewriteRule ^((index|mainkrk|print)\.php)?(\?.*)?$ /krk/%1.html [R=301,QSD,L,nosubreq] RewriteCond &%{QUERY_STRING} &lang=(cs|en|de) [NC] RewriteRule ^((index|mainkrk|print)\.php)?(\?.*)?$ /krk/%1/ [R=301,QSD,L,nosubreq] # Canonization RewriteRule ^cs(?:/(.*))?$ /krk/$1 [R=301,L] RewriteRule ^(en|de)$ /krk/$1/ [R=301,L] RewriteRule ^(mainkrk|index|print).php$ /krk/ [R=301,L] ### Fall back to loading pages through our “CMS” RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-d RewriteRule ^(en|de)/$ /krk/index.php?lang=$1 [END] RewriteRule ^(en|de)/(.+)\.html$ /krk/index.php?page=$2&lang=$1 [END] RewriteRule ^(.+)\.html$ /krk/index.php?page=$1 [END] RewriteRule ^(en|de)/(.+)/$ /krk/index.php?page=$2&lang=$1 [END] RewriteRule ^(.+)/$ /krk/index.php?page=$1 [END]