TYPO3:带有 tx_news 的 Realurl 重复斜杠 - 已解决但未被理解

TYPO3: Realurl duplicate slash with tx_news - resolved but not understood

我只是在 tx_news documentation 上使用官方真实 url conf。这在我的 url 中造成了重复的斜杠。它看起来像这样:

域名.com/post//post-title

要修复它,我发现我必须删除或在 fixedPostVars 中的 tx_newspil[news] 之后放置以下行:

之前:

'fixedPostVars' => [
    'newsDetailConfiguration' => [
        [
            'GETvar' => 'tx_news_pi1[action]',
            'valueMap' => [
                '' => 'detail',
            ],
            'noMatch' => 'bypass'
        ],
        [
            'GETvar' => 'tx_news_pi1[controller]',
            'valueMap' => [
                '' => 'detail',
            ],
            'noMatch' => 'bypass'
        ],
        [
            'GETvar' => 'tx_news_pi1[news]',
            'lookUpTable' => [
                'table' => 'tx_news_domain_model_news',
                '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
            ]
        ]
    ]
]

之后:

'fixedPostVars' => [
    'newsDetailConfiguration' => [
        [
            'GETvar' => 'tx_news_pi1[news]',
            'lookUpTable' => [
                'table' => 'tx_news_domain_model_news',
                '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
            ]
        ],
        [
            'GETvar' => 'tx_news_pi1[action]',
            'valueMap' => [
                '' => 'detail',
            ],
            'noMatch' => 'bypass'
        ],
        [
            'GETvar' => 'tx_news_pi1[controller]',
            'valueMap' => [
                '' => 'detail',
            ],
            'noMatch' => 'bypass'
        ]
    ]
]

要么切换它们,要么简单地删除控制器/动作部件,修复了重复的斜杠。现在我想明白为什么会这样,因为我是 PHP 初学者,所以我不太明白。

感谢大家的帮助!

** 刚刚测试,只有动作部分必须移动或删除才能解决重复的斜杠

发生这种情况是因为 REALURL 配置按照您添加的顺序获取参数。

让我们从您的 post 中获取第一个 REALURL 配置。在此配置中,我希望我的 URL 是这样的:/page/action/controller/post-title.

发生的情况是,您在 post 页面中设置了带有 actioncontroller 参数的新闻插件,然后您没有通过 actionURL 中的 controller,这就是为什么你在那里有 double slashes,因为 actioncontroller 是空的。

Default parameters (e.q controller name, action name, etc), parameters where the value is not required, must be at the end of the configuration, like your last configuration.