33 lines
1.2 KiB
PHP
33 lines
1.2 KiB
PHP
<?php
|
|
|
|
use App\Content\Repository;
|
|
use App\Content\View;
|
|
use App\Controller\SiteController;
|
|
use LaysenseSite\Site;
|
|
use support\Request;
|
|
use Webman\Route;
|
|
|
|
foreach (Site::assets() as $asset) {
|
|
// The global site middleware serves these entries before the maintenance-page middleware.
|
|
Route::add(['GET', 'HEAD'], '/' . $asset, static fn () => response('', 404));
|
|
}
|
|
|
|
foreach ([
|
|
'/main/category/1.html' => '/articles/category/product',
|
|
'/main/category/2.html' => '/articles/category/news',
|
|
'/main/category/3.html' => '/articles/category/announcement',
|
|
'/main/category/5.html' => '/#supported-projects',
|
|
'/main/category/6.html' => '/#partners',
|
|
] as $old => $new) {
|
|
Route::add(['GET', 'HEAD'], $old, static fn () => View::redirect($new, 301));
|
|
}
|
|
|
|
Route::add(['GET', 'HEAD'], '/main/tag/{tag:[^/]+}', static function (Request $request, string $tag) {
|
|
return View::redirect('/articles/tag/' . rawurlencode(rawurldecode($tag)), 301);
|
|
});
|
|
Route::add(['GET', 'HEAD'], '/news/id/{id:[0-9]+}.html', static function (Request $request, string $id) {
|
|
$article = (new Repository())->legacyArticle('/news/id/' . $id . '.html');
|
|
|
|
return $article ? View::redirect('/articles/' . $article['slug'], 301) : (new SiteController())->missing($request);
|
|
});
|