TYPO3 - 404 页面而不是异常

TYPO3 - 404 page instead of exception

我是 运行 TYPO3 6.2

我的日志中出现了一些错误,因为 robots/spiders 试图访问我网站上的错误 URL;当我测试 URL 时,我得到一个 TYPO3 异常页面,其中包含许多有关相关扩展的详细信息:

在这种情况下,我想显示 404 页面。 低于我的参数:

[FE][pageNotFound_handling] = /404/
[FE][pageNotFound_handling_statheader]
[FE][pageUnavailable_handling] = /404/

当我测试 http://www.mycompany.com/xxxxx_anything_xxxx/ 时出现同样的问题,我得到一个 400 Bad request 页面而不是我的 404 页面。

顺便说一句,

http://www.mycompany.com/404/ 很好用,但是 404 页面不显示。我错过了什么?

您的 URL 在请求中向实体传递了错误的值。

这是你的发言URL:http://www.mycompany.com/xxxxx_anything_xxxx/ 你的 URL 是这样生成的:index.php?tx_yourext_plugin[entity]=xxxxx_anything_xxxx

您的控制器中还有一个如下所示的操作:

/**
 * @param \Vendor\ExtensionName\Domain\Model\Entity $entity
 */
public function actionNameAction(\Vendor\ExtensionName\Domain\Model\Entity $entity) 
{
   ...
}

This is wrong because you send a string, and the identifiers are uids, and must be an existing UID.

真实URL修复

[
        'GETvar' => 'tx_yourext_plugin[entity]',
        'lookUpTable' => [
            'table' => 'tx_yourext_domain_model_entity',
            'id_field' => 'uid',
            'alias_field' => 'IF(path_segment!="",path_segment,title)',
            'addWhereClause' => ' AND NOT deleted',
            'useUniqueCache' => 1,
            'languageGetVar' => 'L',
            'languageExceptionUids' => '',
            'languageField' => 'sys_language_uid',
            'transOrigPointerField' => 'l10n_parent',
            'expireDays' => 180,
            'enable404forInvalidAlias' => true
        ]
    ]

或者从你的操作中移除你的依赖注入,它将是这样的:

/**
 * @param string $entity
 */
public function actionNameAction($entity){...}

解决此问题的另一种方法是使用 TypeConverters。 https://api.typo3.org/typo3cms/8/html/class_t_y_p_o3_1_1_c_m_s_1_1_extbase_1_1_property_1_1_type_converter_1_1_object_converter.html

更新

另一个提示是在错别字中使用 config.contentObjectExeceptionHandler = 1。但首先我会尝试解决 link 的问题,因为你向那里传递了不同的数据类型。使用 realURL 你可以稍微控制在动态 url.

中应该传递什么样的数据