Search code examples
urlurl-rewritingtypo3realurl

typo3 realurl show only one segment in url


I was working on realurl's in typo3 and spend hours on working out why typo3 is showing only one segment in url.

site structure looks like this:

enter image description here

and URL that I got for subpage 'munchen-maistrasse' is:

http://www.bernd-gruber.at/munchen-maistrasse/

I want it to be:

http://www.bernd-gruber.at/referenzen/munchen-maistrasse/

This is my server .htaccess file:

<FilesMatch "\.(js|css)$">
  <IfModule mod_expires.c>
    ExpiresActive on
    ExpiresDefault "access plus 7 days"
  </IfModule>
  FileETag MTime Size
</FilesMatch>

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /
RewriteRule ^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ $1.$3 [L]
RewriteRule ^(typo3/|t3lib/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) - [L]
RewriteRule ^typo3$ typo3/index_re.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]

</IfModule>

AddType video/x-m4v .m4v
AddType video/ogg .ogv
AddType video/webm .webm
AddType video/x-m4v .m4v
AddType application/ogg .ogg 

I dont use config.baseURL in typoscript I use:

config.absRefPrefix = /
config.prefixLocalAnchors = all

on my root page. I have runned out of solutions.


Solution

  • You need your own configuration to reach this.

    1) In the Extension Manager -> RealUrl -> Configuration you have to disable the automatic configuration and define there the path to your own realUrl configuration file.

    2) You should make sure that (page).config.tx_realurl_enable = 1 is set.

    3) After making the right realUrl configuration for your website you have to truncate all realUrl caching tables or just remove all ID to Path mappings.

    Here some example of a standard realUrl configuration template:

    <?php
    $realurl_template = array(
    
        'init' => array(
            'appendMissingSlash'    =>  'ifNotFile,redirect',
            'enableCHashCache'      =>  1,
            'enableUrlDecodeCache'  =>  1,
            'enableUrlEncodeCache'  =>  1,
            'emptyUrlReturnValue'   =>  '/'
        ),
    
        'preVars' => array(
            array(
                'GETvar'    =>  'no_cache',
                'valueMap'  =>  array(
                    'nc'    =>  1,
                ),
                'noMatch'   =>  'bypass',
            ),
        ),
    
        'fileName' => array(
            'index' => array(
    
            ),
        ),
    
        'postVarSets' => array(
            '_DEFAULT' => array (
    
            ),
        ),
    
        'pagePath' => array(
            'type' => 'user',
            'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
            'spaceCharacter' => '-',
            'languageGetVar' => 'L',
            'expireDays' => 3,
        )
    );
    
    # Configurate domain names
    $TYPO3_CONF_VARS['EXTCONF']['realurl'] = array(
        '_DEFAULT' => $realurl_template,
        'domain.com' => $realurl_template,
        'www.domain.com' => $realurl_template,
    );
    
    $TYPO3_CONF_VARS['EXTCONF']['realurl']['domain.com']['pagePath']['rootpage_id'] = 1;
    $TYPO3_CONF_VARS['EXTCONF']['realurl']['www.domain.com']['pagePath']['rootpage_id'] = 1;
    
    # Unset template
    unset($realurl_template);
    ?>