带有 realurl 的 TYPO3 7.6.10:页面可访问但前端为非静态链接

TYPO3 7.6.10 with realurl: pages accessible but non-static links in frontend

虽然我已经安装了 realurl 并且我能够访问来自 TYPO3 的页面及其各自的说话 URL 路径段,但前端(即在 TMENU 中)自动生成的链接仍然指向 https://example.com/index.php?id=123 而不是 https://example.com/page-name.

我知道扩展手册中的常见问题解答部分 https://github.com/dmitryd/typo3-realurl/wiki/Notes-for-Integrators#my-urls-still-look-like-indexphpid12345-whats-the-problem 但建议的解决方案是添加

config.tx_realurl_enable = 1

给模板没有解决问题

我在通常的设置中有一个多语言设置,所以参数L携带了语言。它也适用于手动调用正确的地址(即 https://example.com/en/page-name)。

以下是我设置的相关部分:

realurl 扩展设置为手动配置。这是相应的配置文件:

<?php
$TYPO3_CONF_VARS['EXTCONF']['realurl'] = array(
    '_DEFAULT' => array(
            'init' => array(
                    'enableCHashCache' => 1,
                    'appendMissingSlash' => 'ifNotFile',
                    'enableUrlDecodeCache' => 1,
                    'enableUrlEncodeCache' => 1,
                    'postVarSet_failureMode' => '',
            ),
            'redirects' => array(),
            'preVars' => array(
                    array(
                            'GETvar' => 'no_cache',
                            'valueMap' => array(
                                    'nc' => 1,
                            ),
                            'noMatch' => 'bypass',
                    ),
                    array(
                            'GETvar' => 'L',
                            'valueMap' => array(
                                    'en' => '1',
                            ),
                            'valueDefault' => 'en',
                            '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' => 1,
                    'firstHitPathCache' => 1,
            ),
            'fixedPostVars' => array(),
            'postVarSets' => array(
                    '_DEFAULT' => array(
                            // news archive parameters
                            'archive' => array(
                                    array(
                                            'GETvar' => 'tx_ttnews[year]' ,
                                    ),
                                    array(
                                            'GETvar' => 'tx_ttnews[month]' ,
                                            'valueMap' => array(
                                                    'january' => '01',
                                                    'february' => '02',
                                                    'march' => '03',
                                                    'april' => '04',
                                                    'may' => '05',
                                                    'june' => '06',
                                                    'july' => '07',
                                                    'august' => '08',
                                                    'september' => '09',
                                                    'october' => '10',
                                                    'november' => '11',
                                                    'december' => '12',
                                            ),
                                    ),
                            ),
                            // news pagebrowser
                            'browse' => array(
                                    array(
                                            'GETvar' => 'tx_ttnews[pointer]',
                                    ),
                            ),
                            // news categories
                            'select_category' => array (
                                    array(
                                            'GETvar' => 'tx_ttnews[cat]',
                                    ),
                            ),
                            // news articles and searchwords
                            'article' => array(
                                    array(
                                            'GETvar' => 'tx_ttnews[tt_news]',
                                            'lookUpTable' =>array(
                                                    'table' => 'tt_news',
                                                    'id_field' => 'uid',
                                                    'alias_field' => 'title',
                                                    'addWhereClause' => ' AND NOT deleted',
                                                    'useUniqueCache' => 1,
                                                    'useUniqueCache_conf' => array(
                                                            'strtolower' => 1,
                                                            'spaceCharacter' => '-',
                                                    ),
                                            ),
                                    ),
                                    array(
                                            'GETvar' => 'tx_ttnews[backPid]',
                                    ),
                                    array(
                                            'GETvar' => 'tx_ttnews[swords]',
                                    ),
                            ),
                    ),
            ),
            // configure filenames for different pagetypes
            'fileName' => array(
                    'defaultToHTMLsuffixOnPrev' => 1,
                    'index' => array(
                            'print.html' => array(
                                    'keyValues' => array(
                                            'type' => 98,
                                    ),
                            ),
                            '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,
                                    ),
                            ),
                    ),
            ),
    ),
);
?>

模板的 CONSTANTS 部分:

mod.SHARED {
  defaultLanguageFlag = de.gif
  defaultLanguageLabel = Deutsch
}


# Define some vars for use later on
baseURL = https://example.com/
german = 0
english = 1


# real URL config
config.baseURL = {$baseURL}
config.absRefPrefix = {$baseURL}
config.simulateStaticDocuments = 0
config.tx_realurl_enable = 1
config.uniqueLinkVars = 1
config.linkVars = L
config.prefixLocalAnchors = all

plugin {
  tx_srstaticinfo.languageCode = DE
  tx_srlanguagemenu {
    showInactive = 1
    showCurrent = 1
    useSelfLanguageTitle = 1
    languagesUidsList = 0,1
    defaultLanguageISOCode = DE
    defaultCountryISOCode = DE
  }
}

SETUP部分(这里只显示配置和菜单部分):

config.baseURL = {$baseURL}

### Configuration

## menu
lib.menu = HMENU
lib.menu.1 = TMENU
lib.menu.1 {
  NO.allWrap = <li>|</li>
  ACT = 1
  ACT.wrapItemAndSub = <li class="ACT">|</li>
  wrap = <ul class="menu">|</ul>
}

## language menu
plugin.tx_srlanguagemenu.settings {
  useSysLanguageTitle = 0
  defaultLanguageISOCode = DE
  LanguageISOCode = DE

  link.NO.stdWrap = |

  hideIfNoAltLanguages = 1

  #outputs a list (2: list, 1: selection list, 0:flag)
  defaultLayout = 0
  links.stdWrap.split.wrap >
  _CSS_DEFAULT_STYLE >
}


# Building the page
# Default PAGE object:
page = PAGE

# Define the template
page.10 = TEMPLATE

# Our template is a file
page.10.template = FILE
page.10.template.file = fileadmin/template/index.html

# Insert stylesheet in the head of the website
page.stylesheet = {$baseURL}fileadmin/template/style.css

# Work with the subpart "DOCUMENT"
page.10.workOnSubpart = DOCUMENT

# Define the subparts, which are inside the subpart DOCUMENT
page.10.subparts {

  # The subpart LANGMENU outputs a language selection widget
  LANGMENU = HMENU
  LANGMENU < plugin.tx_srlanguagemenu.widgets.menu

  # The subpart CONTENTLEFT outputs the content of the left column
  CONTENTLEFT = CONTENT

  # Display the menu
  CONTENTLEFT < lib.menu

  [...]
}

[...]


# Setting up the language variable "L" to be passed along with links
config.linkVars = L

#values for default language
config.sys_language_uid = 0
config.language = de
config.locale_all = de_DE

# English language, sys_language.uid = 1
[globalVar = GP:L = {$english}]
config.sys_language_uid = 1
config.language = en
config.locale_all = en_GB
[global]
config.tx_realurl_enable = 1

必须在模板的 SETUP 部分,而不是 CONSTANTS 部分。

实际上所有的config配置都必须在SETUP中。常量仅用作设置中的占位符,因此您可以使用预定义常量(包含在默认 TS 或某些扩展 TS 中)或自己定义它们并将引用 {$constantName} 放入您的设置中。

config.simulateStaticDocuments = 0
config.tx_realurl_enable = 1
config.uniqueLinkVars = 1
config.linkVars = L
config.prefixLocalAnchors = all