When updating from TYPO3 8.7 to TYPO3 9.5 you might drop the realurl extension in favor for the new routing feature.
But you might notice, that realurl appended a / to a
To always add an appending /, you can create yourself a route enhancer decorator and put it in your site package.
Create a file in your site package under Classes/Routing/Enhancer/ForceAppendingSlashDecorator.php
with the content:
all() as $route) {
$route->setOption('_decoratedRoutePath', '/' . trim($routePath, '/'));
}
}
/**
* {@inheritdoc}
*/
public function decorateForGeneration(RouteCollection $collection, array $parameters): void
{
foreach ($collection->all() as $routeName => $existingRoute) {
$existingRoutePath = rtrim($existingRoute->getPath(), '/');
$existingRoute->setPath($existingRoutePath . '/');
}
}
}
Please replace set the correct namespace matching your site package.
To register your route enhancer, add the line to your ext_localconf.php
:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['enhancers']['ForceAppendingSlash'] = \MyVendor\SitePackage\Routing\Enhancer\ForceAppendingSlashDecorator::class;
As a last step, put the following code into your site configuration yaml file:
routeEnhancers:
PageTypeSuffix:
type: ForceAppendingSlash
After this adjustments, TYPO3 will always add an appending / to your URLs so the new URLs will match the old ones created by realurl.