Use better addressing scheme for old pages
The subsection indexes should be addressed as directories (URLs ending with a slash). Instead of the non-canonical `section.html` vs `section/section.html`. (Have not yet updated the links.) Also: - Moved the legacy redirects from index.php to .htaccess. - Made the test runner return 1 on failure and print number of failed tests. - Improve test failure message on missing expected redirect.
This commit is contained in:
62
.htaccess
62
.htaccess
@@ -1,17 +1,59 @@
|
||||
ErrorDocument 404 /index.php?page=404
|
||||
ErrorDocument 404 /404.html
|
||||
|
||||
# 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]
|
||||
### Redirect old URLs to new ones
|
||||
## Subpages
|
||||
RewriteCond &%{QUERY_STRING}& &lang=(en|de)&
|
||||
RewriteCond %1@&%{QUERY_STRING}& (en|de)@.*&page=mcr_2009/mcr_2009&
|
||||
RewriteRule .* /krk/%1/mcr_2009/ [R=301,QSD,L]
|
||||
|
||||
RewriteCond &%{QUERY_STRING} &page=([^&]+) [NC]
|
||||
RewriteRule ^((index|mainkrk|print)\.php)?(\?.*)?$ /krk/%1.html [R=301,QSD,L,nosubreq]
|
||||
RewriteCond &%{QUERY_STRING}& &page=mcr_2009/probihani_loucna/probihani_loucna&
|
||||
RewriteRule .* /krk/mcr_2009/probihani_loucna/ [R=301,QSD,L]
|
||||
|
||||
RewriteCond &%{QUERY_STRING} &lang=(cs|en|de) [NC]
|
||||
RewriteRule ^((index|mainkrk|print)\.php)?(\?.*)?$ /krk/%1/ [R=301,QSD,L,nosubreq]
|
||||
RewriteCond &%{QUERY_STRING}& &lang=(en|de)&
|
||||
RewriteCond %1@&%{QUERY_STRING}& (en|de)@.*&page=mcr_2009(/mcr_2009)?&
|
||||
RewriteRule .* /krk/%1/mcr_2009/ [R=301,QSD,L]
|
||||
|
||||
# Canonization
|
||||
RewriteCond &%{QUERY_STRING}& &page=mcr_2009(/mcr_2009)?&
|
||||
RewriteRule .* /krk/mcr_2009/ [R=301,QSD,L]
|
||||
|
||||
RewriteCond &%{QUERY_STRING}& &lang=(en|de)&
|
||||
RewriteCond %1@&%{QUERY_STRING}& (en|de)@.*&page=clanky(/clanky)?&
|
||||
RewriteRule .* /krk/%1/clanky/ [R=301,QSD,L]
|
||||
|
||||
RewriteCond &%{QUERY_STRING}& &page=clanky(/clanky)?&
|
||||
RewriteRule .* /krk/clanky/ [R=301,QSD,L]
|
||||
|
||||
RewriteCond &%{QUERY_STRING}& &lang=(en|de)&
|
||||
RewriteCond %1@&%{QUERY_STRING}& (en|de)@.*&page=(krk_default)?&
|
||||
RewriteRule .* /krk/%1/ [R=301,QSD,L]
|
||||
|
||||
RewriteCond &%{QUERY_STRING}& &page=(krk_default)?&
|
||||
RewriteRule .* /krk/ [R=301,QSD,L]
|
||||
|
||||
## Generic fallback
|
||||
RewriteCond &%{QUERY_STRING}& &lang=(en|de)&
|
||||
RewriteCond %1@&%{QUERY_STRING}& (en|de)@.*&page=([^&]+)/&
|
||||
RewriteRule .* /krk/%1/%2/ [R=301,QSD,L,nosubreq]
|
||||
|
||||
RewriteCond &%{QUERY_STRING}& &lang=(en|de)&
|
||||
RewriteCond %1@&%{QUERY_STRING}& (en|de)@.*&page=([^&]+)&
|
||||
RewriteRule .* /krk/%1/%2.html [R=301,QSD,L,nosubreq]
|
||||
|
||||
RewriteCond &%{QUERY_STRING}& &page=([^&]+)/&
|
||||
RewriteRule .* /krk/%1/ [R=301,QSD,L,nosubreq]
|
||||
|
||||
RewriteCond &%{QUERY_STRING}& &page=([^&]+)&
|
||||
RewriteRule .* /krk/%1.html [R=301,QSD,L,nosubreq]
|
||||
|
||||
# No page selected
|
||||
RewriteCond &%{QUERY_STRING}& &lang=(en|de)&
|
||||
RewriteRule .* /krk/%1/ [R=301,QSD,L,nosubreq]
|
||||
|
||||
# No page selected
|
||||
RewriteCond &%{QUERY_STRING}& &lang=cs&
|
||||
RewriteRule .* /krk/ [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]
|
||||
|
||||
@@ -228,14 +228,10 @@ if ($page !== '') {
|
||||
}
|
||||
if ($page == 'mcr_2009') {
|
||||
include "./pages/mcr_2009/mcr_2009$jazycek.php";
|
||||
} elseif ($page == 'mcr_2009/probihani_loucna') {
|
||||
include "./pages/mcr_2009/probihani_loucna/probihani_loucna$jazycek.php";
|
||||
} elseif ($page == 'clanky') {
|
||||
include "./pages/clanky/clanky$jazycek.php";
|
||||
} elseif ($page == 'akce_ob') {
|
||||
include "./pages/akce_ob/akce_ob$jazycek.php";
|
||||
} elseif ($page == 'akce_litvinov') {
|
||||
include "./pages/akce_litvinov/akce_litvinov$jazycek.php";
|
||||
} elseif ($page == 'ski_krusnohori') {
|
||||
include './pages/ski_krusnohori/ski_krusnohori' . $jazycek . '.php';
|
||||
} elseif ($lang === 'cs' && file_exists(__DIR__ . "/pages/$escaped_page.php")) {
|
||||
include "./pages/$escaped_page.php";
|
||||
} elseif (file_exists(__DIR__ . "/pages/$escaped_page-$lang.php")) {
|
||||
|
||||
Reference in New Issue
Block a user