简体   繁体   中英

Typo3: RealURL and Ext:news – News URLs are not rewritten

I'm runnning Typo3 6.2.4 with RealURL 1.12.8 and News (tx_news) 3.0.1. Using the automatic configuration from RealURL rewrites the URLs for "normal" pages, but not for news. The generated links look like this:

index.php?id=5&tx_news_pi1%5Bnews%5D=4&tx_news_pi1%5Bcontroller%5D=News&tx_news_pi1%5Baction%5D=detail&cHash=706379a0ef43d4020448c5193f865bf1

This is what automatic configuration gives me. I've just inserted the part from http://docs.typo3.org/typo3cms/extensions/news/Main/Administration/Realurl/Index.html . At the moment I'm not interested in creating a special kind of rewritten URL, I just want to get RealURL rewrite the news URLs. Once that's running, I think I'll get the rest figured out.

<?php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']=array (
  '_DEFAULT' => 
  array (
    'init' => 
    array (
      'enableCHashCache' => true,
      'appendMissingSlash' => 'ifNotFile,redirect',
      'adminJumpToBackend' => true,
      'enableUrlDecodeCache' => true,
      'enableUrlEncodeCache' => true,
      'emptyUrlReturnValue' => '/',
    ),
    'pagePath' => 
    array (
      'type' => 'user',
      'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
      'spaceCharacter' => '-',
      'languageGetVar' => 'L',
      'rootpage_id' => '1',
    ),
    'fileName' => 
    array (
      'defaultToHTMLsuffixOnPrev' => 0,
      'acceptHTMLsuffix' => 1,
      'index' => 
      array (
        'print' => 
        array (
          'keyValues' => 
          array (
            'type' => 98,
          ),
        ),
      ),
    ),
    'postVarSets' => 
    array (
      '_DEFAULT' => 
      array (
// EXT:news start
'news' => array(
        array(
                'GETvar' => 'tx_news_pi1[action]',
        ),
        array(
                'GETvar' => 'tx_news_pi1[controller]',
        ),
        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,
                ),
        ),
),
// EXT:news end
      ),
    ),
  ),
);

It turned out that my realurl_conf.php was correct, but the TypoScript configuration part was missing. As soon as I put those lines in the template setup of my root page, Typo3 started to rewrite the URLs:

config.absRefPrefix = /
config.tx_realurl_enable = 1
config.uniqueLinkVars = 1
# dont forget to set the allowed range - otherwise anything else could be inserted
config.linkVars = L(0-3)

Source:

http://wiki.typo3.org/Realurl/manual#TypoScript_configuration http://docs.typo3.org/typo3cms/extensions/realurl/Realurl/Configuration/HandlingRelativeLinksWithSpeakingUrls/Index.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM