TYPO3 realURL无法生成中文网址

时间:2017-03-24 16:20:52

标签: php typo3 typo3-6.2.x

我的TYPO3中有中文内容,我需要生成网址, 中文和生成的URL中的内容为空: 我的中文ID = 8。 如果没有RealURL,我会显示我的页面,但是有URL:

http://localhost/zh/locations-chinese/?tx_locations_locationsfe%5Blocation%5D=104&tx_locations_locationsfe%5BmyId%5D=104&tx_locations_locationsfe%5Baction%5D=list&tx_locations_locationsfe%5Bcontroller%5D=Location&cHash=b864e25ff5fba24b2e44ce0723265881

这就是我需要产生的东西:

http://localhost/locations/berlin.html?L=8&cHash=32a89be23eb7dc2516893bdf0e1cc424

http://localhost/locations/柏林.html?L=8&cHash=32a89be23eb7dc2516893bdf0e1cc424

这就是我得到的:

http://localhost/locations.html?L=8&cHash=32a89be23eb7dc2516893bdf0e1cc424

有错误:

  

找不到页面

     
    

原因:无法验证请求参数(& cHash比较     失败)

  

那是我的/typo3cong/realurl_conf.php

<?php
$TYPO3_CONF_VARS['FE']['addRootLineFields'].= ',tx_realurl_pathsegment';
$TYPO3_CONF_VARS['EXTCONF']['realurl'] = array(
    '_DEFAULT' => array(
        'init' => array(
            'enableCHashCache' => 1,
            //'appendMissingSlash' => 'ifNotFile',
            'enableUrlDecodeCache' => 1,
            'enableUrlEncodeCache' => 1,
            'postVarSet_failureMode' => '',
            'EnableAllUnicodeLetters' => true,
            'doNotRawUrlEncodeParameterNames' => true,

        ),
        'redirects' => array(),
        'preVars' => array(
            array(
                'GETvar' => 'no_cache',
                'valueMap' => array(
                    'nc' => 1,
                ),
                'noMatch' => 'bypass',
            ),
        ),
        'pagePath' => array(
            'type' => 'user',
            'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
            'spaceCharacter' => '-',
            'languageGetVar' => 'L',
            'languageExceptionUids' => '8',
            'expireDays' => 7,
            'rootpage_id' => 1,
            'firstHitPathCache' => 1,
        ),
        'fixedPostVars' => array(
            162 => array(
                array(
                    'GETvar' => 'tx_locations_locationsfe[controller]',
                    'valueMap' => array(
                        //'action' => 'detail',
                    ),
                    'noMatch' => 'bypass',
                ),
                array(
                    'GETvar' => 'tx_locations_locationsfe[action]',
                    'valueMap' => array(
                        //'detail' => 'list',
                    ),
                    'noMatch' => 'bypass',
                ),
                array(
                    'GETvar' => 'tx_locations_locationsfe[location]',
                    'valueMap' => array(
                        //'action' => 'detail',
                    ),
                    'noMatch' => 'bypass',

                ),
                array(
                    'GETvar' => 'tx_locations_locationsfe[myId]',
                    'lookUpTable' => array(
                        'table' => 'tx_locations_domain_model_location',
                        'id_field' => 'uid',
                        'alias_field' => 'title',
                        'addWhereClause' => ' AND NOT deleted',
                        'useUniqueCache' => 1,
                        'useUniqueCache_conf' => array(
                            'strtolower' => 1,
                            'spaceCharacter' => '-',
                        ),
                        // language support (translated urls)
                        'languageGetVar' => 'L',
                        'languageExceptionUids' => '',
                        'languageField' => 'sys_language_uid',
                        'transOrigPointerField' => 'l10n_parent',
                        'autoUpdate' => 1,
                        'expireDays' => 180,
                    ),

                ),
            ),
            163 => array(
                array(
                    'GETvar' => 'tx_locations_locationsfe[controller]',
                    'valueMap' => array(
                        //'action' => 'detail',
                    ),
                    'noMatch' => 'bypass',
                ),
                array(
                    'GETvar' => 'tx_locations_locationsfe[action]',
                    'valueMap' => array(
                        //'detail' => 'listprice',
                    ),
                    'noMatch' => 'bypass',
                ),
                array(
                    'GETvar' => 'tx_locations_locationsfe[location]',
                    'valueMap' => array(
                        //'action' => 'detail',
                    ),
                    'noMatch' => 'bypass',

                ),
                array(
                    'GETvar' => 'tx_locations_locationsfe[myId]',
                    'lookUpTable' => array(
                        'table' => 'tx_locations_domain_model_location',
                        'id_field' => 'uid',
                        'alias_field' => 'title',
                        'addWhereClause' => ' AND NOT deleted',
                        'useUniqueCache' => 1,
                        'useUniqueCache_conf' => array(
                            'strtolower' => 1,
                            'spaceCharacter' => '-',
                        ),
                        // language support (translated urls)
                        'languageGetVar' => 'L',
                        'languageExceptionUids' => '',
                        'languageField' => 'sys_language_uid',
                        'transOrigPointerField' => 'l10n_parent',
                        'autoUpdate' => 1,
                        'expireDays' => 180,
                    ),

                ),
            ),
        ),
        'postVarSets' => array(
            '_DEFAULT' => array (),
        ),
        // configure filenames for different pagetypes
        'fileName' => array(
            'defaultToHTMLsuffixOnPrev' => 1,
            'index' => array(
                'print.html' => array(
                    'keyValues' => array(
                        'type' => 98,
                    ),
                ),
                'sitemap.xml' => array(
                    'keyValues' => array(
                        'type' => 200,
                    ),
                ),
                'rss.xml' => array(
                    'keyValues' => array(
                        'type' => 100,
                    ),
                ),
                'rss091.xml' => array(
                    'keyValues' => array(
                        'type' => 101,
                    ),
                ),
                'rdf.xml' => array(
                    'keyValues' => array(
                        'type' => 102,
                    ),
                ),
                'atom.xml' => array(
                    'keyValues' => array(
                        'type' => 103,
                    ),
                ),
            ),
        ),
    ),
);
?>

2 个答案:

答案 0 :(得分:2)

据我所知,您的配置中有拼写错误。 它应该读为小写'enableAllUnicodeLetters' => true

Unicode字符会自动进行网址编码。

答案 1 :(得分:0)

URL只能包含ASCII字符,并且“不能”包含/理解Unicode字符,例如UTF-8。您需要使用所谓的“百分比编码”来编码(或替换)任何Unicode字符(中文)。