Search code examples
content-management-systemtypo3typoscripttypo3-7.6.xrealurl

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


Although I have installed realurl and I am able to access pages from TYPO3 with their respective speaking URL path segments, the auto-generated links in the frontend (i.e. in the TMENU) still point to https://example.com/index.php?id=123 and not to https://example.com/page-name.

I am aware of the FAQ section in the extension manual https://github.com/dmitryd/typo3-realurl/wiki/Notes-for-Integrators#my-urls-still-look-like-indexphpid12345-whats-the-problem but the suggested solution of adding

config.tx_realurl_enable = 1

to the template did not solve the problem.

I have a multi-language setup in the usual setup so that the parameter L carries the language. It also works when manually calling the correct address (i.e. https://example.com/en/page-name).

Here are the relevant parts of my setup:

The realurl extension is set to manual configuration. Here is the respective config file:

<?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 part of the template:

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 part (here only the configuration and menu parts are shown):

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]

Solution

  • config.tx_realurl_enable = 1
    

    has to be in the SETUP part, not the CONSTANTS part of your template.

    Actually all of the config configuration has to be in SETUP. Constants are only used as placeholders in the setup, so you can use either predefined constants (which are included in the default TS or some extension TS) or define them yourself and put the reference {$constantName} in your setup.

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