Translations
Info
All page names need to be in English.
en da  de  fr  it  ja  km  nl  ru  zh

Realurl/testing

From TYPO3Wiki
(Redirected from EXT/realurl/testing)
Jump to: navigation, search

<< Back to Extension manuals page

[edit]

Other RealURL topic: testing | manual in the Wiki | a project to write a configuration editor for RealURL

By: Sylvain Viart 17:43, 30 Oct 2004 (CEST)


This page describes my experience from trying to get RealURL running. For the complete manual see EXT/realurl/manual!

Configuring RealURL

The documentation of RealURL is not so bad, but is far from user friendly. The first statement about the configuration is good enough to get started.

  1. Configure Apache and mod_rewrite
  2. Configure the extension
    • in the extension manager: Either use automatic configuration or use manual configuration in realurl_conf.php.
    • in typo3conf/realurl_conf.php (if you chose to use manual configuration)

At mod_rewrite setup rules, it might already cause problem.

Be careful that Apache behaves differently if the rules are inside a VirtualHost configuration or at another place. Here is a sample of a working VirtualHost configuration.

File: httpd.conf

##
## httpd.conf -- Apache HTTP server configuration file
##
<VirtualHost 10.0.1.2>
    ServerAdmin sylvain (at) ledragon.net
    DocumentRoot /home/www/typo3/camping/
    ServerName camping.ledragon.net
    ErrorLog /home/www/typo3/log/camping_error.log
    CustomLog /home/www/typo3/log/camping_access.log common

   <Directory />
      Options Indexes Includes FollowSymLinks MultiViews
      AllowOverride All
      DirectoryIndex index.php index.html index.htm

      # RealURL TYPO3 extension mod_rewrite configuration
      RewriteEngine On
      RewriteRule ^/typo3$ - [L]
      RewriteRule ^/typo3/.*$ - [L]

      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-l
      RewriteRule .* /index.php
   </Directory>

#   RewriteLog /home/www/typo3/log/rewrite.log
#   RewriteLogLevel 0

   UseCanonicalName On

</VirtualHost>

It does not work well if the rewrite rules are not inside <Directory>, because the VirtualHost location (path) is not correctly prepended by mod_rewrite. You can see it in debug mode RewriteLogLevel > 3, remove the old log file, and restart apache.

mod_rewrite rules

Use the mod_rewrite rules proposed in the RealURL extension manual. Basically it proposes using the rules, which come with the _.htaccess file of the TYPO3 core.

RealURL configuration in realurl_conf.php

What I have:

  • my.domaine/index.php?id=12&L=1
  • my.domaine/index.php?id=12
  • my.domaine/index.php?id=12&L=4

What I want:

  • my.domaine/en/the-nice-page-name.html
  • my.domaine/en/the-nice-page-name/subpage-name.html

I don't want any folder links ending with a slash, only page links ending with ".html". Only the site root can be served by http://my.domain/. After that the link should be http://my.domain/fr/accueil.html or http://my.domain/en/home.html.

Your time saver

Have TYPO3 create absolute URLs, in Template TSconfig (Setup).

config.absRefPrefix = http://my.domaine/subfolder/

This should prepend all internal links with http://my.domain/subfolder/ in your page. You may check [globalString = ENV:HTTP_HOST=www.domain.tld] to set different absRefPrefix for each HTTP_HOST.

Clear DB cache

  • tx_realurl_pathdata NOT clearead on clear all cache, because it can hold old page name pointers. Actually, this table is not a cache; its data is not only temporary. Instead, this data should not be removed.
    • You can clear it manually with PhpMyAdmin. Empty DB tx realurl pathcache.png
  • tx_realurl_uniqalias ??

BE show mode configuration

BE show mode, is when you want to see a page view from inside the BE, by selecting the Show function Magnify.png.

Having real URLs there seems not currently supported...

Current RealURL config

My current config, almost works.

Everything seems to work except some glitches, but tend to be self removed by page caching.

Root page translation is not working.

I got : http://camp.ledragon.net/it.html I would like http://camp.ledragon.net/it/home.html

This config is a modified version of the one available from http://web.archive.org/web/20050206182548/http://typo3.lehmano.de/realurl-config.html

typo3conf/realurl_conf.php:

PHP script:
 // RealURL configuration.
 //
  $TYPO3_CONF_VARS['EXTCONF']['realurl'] = array(
     'camp.ledragon.net' => array(
        'preVars' => array(
           '0' => array(
              'GETvar' => 'L',
              'valueMap' => array(
                 'fr' => '0',
                 'en' => '1',
                 'it' => '4',
              ),
              'valueDefault' => 'fr',
          ),
 
       ),
 
        'fileName' => array(
           'defaultToHTMLsuffixOnPrev' => '1',
       ),
 
        'pagePath' => array(
           'spaceCharacter' => '-',
           'expireDays' => '3',
           'rootpage_id' => '2',
       ),
 
        'fixedPostVars' => array(
       ),
 
    ),
 
 );

Basically this configures RealURL for the domain camp.ledragon.net. For this domain, the Get parameter L should be transfered to the according pre variable depending on the value of that variable.

More advanced example of realurl_conf.php configuration

This example is for a site which could run tt_news extension. I have added some comments.

typo3conf/realurl_conf.php:

PHP script:
 // realurl config
 $TYPO3_CONF_VARS['EXTCONF']['realurl'] = array(
    //No default configuration. If no domain gets matched, e.g. typo3.lehmano.de, there will be no configuration at all.
    '_DEFAULT' => array(),
    //<b>configuration matching only this domain</b>
    'typo3.lehmano.de' => array(
         'init' => array(
             // 'appendMissingSlash' => 'ifNotFile',
         ),
         'preVars' => array(
             //<b>match &no_cache=1 with path prefix <strong>/nc</strong></b>
             array(
                 'GETvar' => 'no_cache',
                 'valueMap' => array(
                     'nc' => 1,
                 ),
                 'noMatch' => 'bypass',
             ),
             //<b>multiple language matching L=2 is replaced by <strong>/dk</strong></b>
             //<b>value are user defiened depending of the order you've inserted your</b>
             //<b>alternative language in TYPO3. See sys_language table for ID</b>
             array(
                 'GETvar' => 'L',
                 'valueMap' => array(
                     'dk' => '2', 
                     // 'dansk' => '2',
                     'de' => '1', 
                     // 'deutsch' => '1',
                 ),
                 'noMatch' => 'bypass',
             ),
          ),
          // <b>use extended page name rendering</b>
          // <b>page names are converted to readable page/sub-page/sub-sub-page.html</b>
         'pagePath' => array(
             'spaceCharacter' => '-',
             'expireDays' => 7,
             'rootpage_id' => 454, 
         ),
         'fixedPostVars' => array(),
         // <b>match extension parameter</b>
         'postVarSets' => array(
             '_DEFAULT' => array(
                 // archive
                 'period' => array(
                     array(
                         'condPrevValue' => -1,
                         'GETvar' => 'tx_ttnews[pS]' , 
                         // 'valueMap' => array(
                         // 
                         // )
                     ),
                     array(
                         'GETvar' => 'tx_ttnews[pL]' , 
                         // 'valueMap' => array(
                         // 
                         // )
                     ),
                     array(
                         'GETvar' => 'tx_ttnews[arc]' ,
                         'valueMap' => array(
                             'archived' => 1,
                             'non-archived' => -1,
                         )
                      ),
                 ), 
                 // pagebrowser
                 'browse' => array(
                     array(
                         'GETvar' => 'tx_ttnews[pointer]',
                     ),
                 ),
                 'select' => array (
                     array(
                         'GETvar' => 'tx_ttnews[cat]',
                         'lookUpTable' => array(
                             'table' => 'tt_news_cat',
                             'id_field' => 'uid',
                             'alias_field' => 'title',
                             'addWhereClause' => ' AND NOT deleted',
                             'useUniqueCache' => 1,
                             'useUniqueCache_conf' => array(
                                 'strtolower' => 1,
                             ),
                         ),
                     ),
                 ),
 
 		         'article' => array(
                       array(
                           'GETvar' => 'tx_ttnews[backPid]',
                       ),
                       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[swords]'
                       ),
                  ),
             ),
         ),
         // <b>map some type to file name: rss.xml = &type=100</b>
         'fileName' => array(
              'index' => array(
                   'rss.xml' => array(
                        'keyValues' => array(
                             'type' => 100,
                        ),
                   ), 
              ),
              // <b>add .html suffix to the end of the generated path</b>
              'defaultToHTMLsuffixOnPrev' => 1,
         ),
     )
 );

Language selector

Here is a TypoScript snippet I use to produce the language selector. It works with RealURL:

lib.langMenu = HMENU
lib.langMenu {
  special = language
  special.value = 0,1
  special.normalWhenNoLanguage = 0
  addQueryString = 1
  1 = TMENU
  1 {
    NO = 1
    NO {
        allWrap = <li>|</li>
        stdWrap2.noTrimWrap = | | |
        stdWrap.override = Deutsch || English
        ATagParams = class="lang-switcher-de" || class="lang-switcher-en"
    }

    ACT < .NO
    ACT = 1
    ACT.allWrap = <li class="active">|</li>

    wrap = <ul class="pull-right language"><li class="hidden-xs">Language:</li>|</ul>
  }
}

Modified Language selector

However, I cannot use the above snippet as is, but I need some modifications in that code:

  • I do not have two languages, but three and the language IDs are different from those in the above snippet:
    • fr: 0
    • en: 1
    • it: 4
  • Also for me, I need the default language to be French.

I have adjusted the code as follows:

lib.langMenu = HMENU
lib.langMenu {
  special = language
  special.value = 0,1,4
  special.normalWhenNoLanguage = 0
  addQueryString = 1
  1 = TMENU
  1 {
    NO = 1
    NO {
        allWrap = <li>|</li>
        stdWrap2.noTrimWrap = | | |
        stdWrap.override = French || English || Italian
        ATagParams = class="lang-switcher-dfr" || class="lang-switcher-en" || class="lang-switcher-it"
    }

    ACT < .NO
    ACT = 1
    ACT.allWrap = <li class="active">|</li>

    wrap = <ul class="pull-right language"><li class="hidden-xs">Language:</li>|</ul>
  }
}

I then use lib.langMenu for one of the markers in my HTML template by mapping it to that marker in the TypoScript setup section of my TypoScript template.

Other RealURL examples

Put your own working example in the following page: