TYPO3 - 404自定义页面永不显示,仅400

时间:2018-06-01 12:59:59

标签: typo3 typo3-6.2.x realurl

在我的网站配置下面:

  • TYPO3 6.2
  • RealURL

我有一个www.mysite.com/404/页面,完美无缺。 但是当出现错误时,TYPO3从不重定向到它,我得到一个400 Bad Request页。

我已经做过:

  • 编辑我的localconf.php

enter image description here

  • 通过“所有配置”后端模块进行编辑

enter image description here

  • 编辑realurl_conf.php

enter image description here

我错过了什么?

1 个答案:

答案 0 :(得分:0)

我总是喜欢(在realurl_conf.php中):

<?php


$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'] = array (
    '_DEFAULT' => array (
        'init' => array (
            'enableCHashCache' => '1',
            'appendMissingSlash' => 'ifNotFile',
            'enableUrlDecodeCache' => '1',
            'enableUrlEncodeCache' => '1',
        ),
        'redirects' => array (
        ),
        'preVars' => array (
            '0' => array (
                'GETvar' => 'no_cache',
                'valueMap' => array (
                    'nc' => '1',
                ),
                'noMatch' => 'bypass'
            ),
            '1' => array (
                'GETvar' => 'L',
                'valueMap' => array (
                    'nl' => '0',
                    'en' => '2',
                    'de' => '1',
                ),
                'noMatch' => 'bypass',
            ),
            '2' => array (
                'GETvar' => 'lang',
                'valueMap' => array (
                    'de' => 'de',
                    'en' => 'en',
                    'nl' => 'nl'
                ),
                'noMatch' => 'bypass',
            ),
        ),
        'pagePath' => array (
            'type' => 'user',
            'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
            'spaceCharacter' => '-',
            'languageGetVar' => 'L',
            'expireDays' => '7',
            'rootpage_id' => $rootpageId,
        ),
        'fixedPostVars' => array(
                'newsDetailConfiguration' => array(
                        array(
                                'GETvar' => 'tx_news_pi1[action]',
                                'valueMap' => array(
                                        'detail' => '',
                                ),
                                'noMatch' => 'bypass'
                        ),
                        array(
                                'GETvar' => 'tx_news_pi1[controller]',
                                'valueMap' => array(
                                        'News' => '',
                                ),
                                'noMatch' => 'bypass'
                        ),
                        array(
                                'GETvar' => 'tx_news_pi1[news]',
                                'lookUpTable' => array(
                                        'table' => 'tx_news_domain_model_news',
                                        'id_field' => 'uid',
                                        'alias_field' => 'title',
                                        'addWhereClause' => ' AND NOT deleted',
                                        'useUniqueCache' => 1,
                                        'useUniqueCache_conf' => array(
                                                'strtolower' => 1,
                                                'spaceCharacter' => '-'
                                        ),
                                        'languageGetVar' => 'L',
                                        'languageExceptionUids' => '',
                                        'languageField' => 'sys_language_uid',
                                        'transOrigPointerField' => 'l10n_parent',
                                        'autoUpdate' => 1,
                                        'expireDays' => 180,
                                )
                        )
                ),
                'newsCategoryConfiguration' => array(
                        array(
                                'GETvar' => 'tx_news_pi1[overwriteDemand][categories]',
                                'lookUpTable' => array(
                                        'table' => 'sys_category',
                                        'id_field' => 'uid',
                                        'alias_field' => 'title',
                                        'addWhereClause' => ' AND NOT deleted',
                                        'useUniqueCache' => 1,
                                        'useUniqueCache_conf' => array(
                                                'strtolower' => 1,
                                                'spaceCharacter' => '-'
                                        )
                                )
                        )
                ),
                'newsTagConfiguration' => array(
                        array(
                                'GETvar' => 'tx_news_pi1[overwriteDemand][tags]',
                                'lookUpTable' => array(
                                        'table' => 'tx_news_domain_model_tag',
                                        'id_field' => 'uid',
                                        'alias_field' => 'title',
                                        'addWhereClause' => ' AND NOT deleted',
                                        'useUniqueCache' => 1,
                                        'useUniqueCache_conf' => array(
                                                'strtolower' => 1,
                                                'spaceCharacter' => '-'
                                        )
                                )
                        )
                ),
                'CompanyDetailConfiguration' => array(
                        array(
                                'GETvar' => 'tx_dswmediacompanies_companies[action]',
                                'valueMap' => array(
                                        'detail' => '',
                                ),
                                'noMatch' => 'bypass'
                        ),
                        array(
                                'GETvar' => 'tx_dswmediacompanies_companies[controller]',
                                'valueMap' => array(
                                        'Companies' => '',
                                ),
                                'noMatch' => 'bypass'
                        ),
                        array(
                                'GETvar' => 'tx_dswmediacompanies_companies[uid]',
                                'lookUpTable' => array(
                                        'table' => 'tx_dswmediacompanies_domain_model_companies',
                                        'id_field' => 'uid',
                                        'alias_field' => 'name',
                                        'addWhereClause' => ' AND NOT deleted',
                                        'useUniqueCache' => 1,
                                        'useUniqueCache_conf' => array(
                                                'strtolower' => 1,
                                                'spaceCharacter' => '-'
                                        ),
                                        'languageGetVar' => 'L',
                                        'languageExceptionUids' => '',
                                        'languageField' => 'sys_language_uid',
                                        'transOrigPointerField' => 'l10n_parent',
                                        'autoUpdate' => 1,
                                        'expireDays' => 180,
                                )
                        )
                ),
                '15' => 'newsDetailConfiguration',
        ),
        'postVarSets' => array (
            '_DEFAULT' => array (
                'b' => array (
                    array (
                        'GETvar' => 'tx_example[uid]',
                        'lookUpTable' => array (
                            'table' => 'tx_dswmediacompanies_domain_model_companies',
                            'id_field' => 'uid',
                            'alias_field' => 'name',
                            'addWhereClause' => ' AND NOT deleted',
                            'useUniqueCache' => '1',
                            'useUniqueCache_conf' => array (
                                'strtolower' => '1',
                                'spaceCharacter' => '-',
                            ),
                        ),
                    ),
                    array (
                        'GETvar' => 'tx_example[action]',
                        'lookUpTable' => array (
                            'table' => 'tx_example_domain_model_companies',
                            'id_field' => 'uid',
                            'alias_field' => 'name',
                            'addWhereClause' => ' AND NOT deleted',
                            'useUniqueCache' => '1',
                            'useUniqueCache_conf' => array (
                                'strtolower' => '1',
                                'spaceCharacter' => '-',
                            ),
                        ),
                    ),  
                ),
                'controller' => array(
                        array(
                                'GETvar' => 'tx_news_pi1[action]',
                                'noMatch' => 'bypass'
                        ),
                        array(
                                'GETvar' => 'tx_news_pi1[controller]',
                                'noMatch' => 'bypass'
                        )
                ),

                'dateFilter' => array(
                        array(
                                'GETvar' => 'tx_news_pi1[overwriteDemand][year]',
                        ),
                        array(
                                'GETvar' => 'tx_news_pi1[overwriteDemand][month]',
                        ),
                ),
                'page' => array(
                        array(
                                'GETvar' => 'tx_news_pi1[@widget_0][currentPage]',
                        ),
                ),
                // 'news' => array (
                //     0 => array (
                //         'GETvar' => 'tx_news_pi1[news]',
                //         'lookUpTable' => array (
                //             'table' => 'tx_news_domain_model_news',
                //             'id_field' => 'uid',
                //             'alias_field' => 'title',
                //             'useUniqueCache' => 1,
                //             'useUniqueCache_conf' => array (
                //                 'strtolower' => 1,
                //                 'spaceCharacter' => '-',
                //             ),
                //         ),
                //     ),
                // ),
            ),
        ),
        'fileName' => array (
            'defaultToHTMLsuffixOnPrev' => false,
            'index' => array (
                'rss.xml' => array (
                    'keyValues' => array (
                        'type' => '100',
                    ),
                ),
                'rss2.xml' => array (
                    'keyValues' => array (
                        'type' => '101',
                    ),
                ),
                'rdf.xml' => array (
                    'keyValues' => array (
                        'type' => '102',
                    ),
                ),
                'atom.xml' => array (
                    'keyValues' => array (
                        'type' => '103',
                    ),
                ),
                'sitemap.xml' => array (
                    'keyValues' => array (
                        'type' => '841132',
                    ),
                ),
                'robots.txt' => array (
                    'keyValues' => array (
                        'type' => '841133',
                    ),
                ),
            ),
        ),
    ),
); 

switch($_SERVER['HTTP_HOST']) {
    case 'example.nl':
    case 'www.example.nl':
        $TYPO3_CONF_VARS['FE']['pageNotFound_handling'] = 'index.php?id=4';
        $TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader'] = 'HTTP/1.0 404 Not Found';
        $rootpageId = 1;
    break;
    case 'othersite.nl':
    case 'www.othersite.nl':
        $TYPO3_CONF_VARS['FE']['pageNotFound_handling'] = 'index.php?id=68';
        $TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader'] = 'HTTP/1.0 404 Not Found';
        $rootpageId = 23;
    break;
}


?>

希望有所帮助:)

更新:

    func validate(text: String) -> Bool {

    let checkRegex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"


    var returnValue = true

    let regex = try! NSRegularExpression(pattern: ".*[^A-Za-z0-9].*", options: NSRegularExpression.Options())
    if regex.firstMatch(in: text, options: NSRegularExpression.MatchingOptions(), range:NSMakeRange(0, text.characters.count)) != nil {
        let matches = charError(for: "\\*\\&\\^?", in: text)
        let errorToString = String(describing: matches)
        errorLabel.text = "invalid: \(errorToString)"
    }


    do {
        let regex = try NSRegularExpression(pattern: checkRegex)
        let nsString = text as NSString
        let results = regex.matches(in: text, options: [], range: NSRange(location: 0, length: nsString.length))
        charError(for: checkRegex, in: text)

        if results.count == 0 {
            returnValue = false
        }
    }
        catch let error as NSError {
            print("default error")
            returnValue = false
        }
        return returnValue
    }




func charError(for regex: String, in text: String) -> [String] {


    do {
        let regex = try NSRegularExpression(pattern: regex)
        let nsString = text as NSString
        let results = regex.matches(in: text, range: NSRange(location: 0, length: nsString.length))
        return results.map { nsString.substring(with: $0.range) }
    } catch let error {
        print("invalid char: \(error.localizedDescription)")
        return []
        }
    }