如果routeEnhancercers配置了“ .html”后缀,是否仍然没有像“ www.mysite.com”这样的基本URL?
我认为这应该是一个基本功能,但是我找不到任何解决方案。重定向首页链接不是一种选择,因为规范人员仍指向错误的URL(www.mysite.com/index.html)
有什么解决办法吗?
我的配置如下:
routeEnhancers:
PageTypeSuffix:
type: PageType
default: '.html'
index: index
map:
.html: 0
答案 0 :(得分:1)
reported issue on forge.typo3.org仍然开放(截至2019年9月)。
对于时间流逝,您可以提供自定义PageType装饰器,以达到理想的效果。报告该问题的开发人员Daniel Dorndorf对此发布了源代码:
<?php
namespace Brand\Extensionname\Classes\Routing\Enhancer;
use TYPO3\CMS\Core\Routing\Enhancer\PageTypeDecorator;
use TYPO3\CMS\Core\Routing\RouteCollection;
/**
* Class CustomPageTypeDecorator
*/
class CustomPageTypeDecorator extends PageTypeDecorator
{
public const IGNORE_INDEX = [
'/index.html',
'/index/',
];
public const ROUTE_PATH_DELIMITERS = ['.', '-', '_', '/'];
/**
* @param \TYPO3\CMS\Core\Routing\RouteCollection $collection
* @param array $parameters
*/
public function decorateForGeneration(RouteCollection $collection, array $parameters): void
{
parent::decorateForGeneration($collection, $parameters);
/**
* @var string $routeName
* @var \TYPO3\CMS\Core\Routing\Route $route
*/
foreach ($collection->all() as $routeName => $route) {
$path = $route->getPath();
if (true === \in_array($path, self::IGNORE_INDEX, true)) {
$route->setPath('/');
}
}
}
}
<?php
defined('TYPO3_MODE') or die();
// Register custom PageTypeDecorator:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['enhancers'] += ['CustomPageType' => \Brand\Extensionname\Classes\Routing\Enhancer\CustomPageTypeDecorator::class];
将其添加到模板扩展中,调整PHP名称空间(\Brand\Extensionname\
),就可以完成。
PageTypeSuffix:
type: CustomPageType
default: '.html'
index: 'index'
map:
'.html': 0