skip to Main Content

I’m using a website running TYPO3 6.2 with Realurl extension.

In the tree I created a "Cars" page with ID #66 and with "cars/" as speaking url path segment. My page is now available with https://www.mywebsite.com/cars/. Cool.

What I need, if going on https://www.mywebsite.com/cars/audi, is to retrieve the audi as a GET variable (GP:car_brand) in Typoscript but current Typo3 default behavior is to search for a audi page below the existing cars page… and then display a 404 error.

What I have already tried:

1/ Adding a RewriteRule inside the .htaccess: RewriteRule ^cars/(.*)$ /index.php?id=66&car_brand=/$1 [P]. It works but the user is redirected to https://www.mywebsite.com/cars/?car_brand=audi, and we really need to keep the cars/audi/ URL scheme which is more SEO compliant / user friendly.

2/ Adding custom configuration inside my realurl_conf.php postVarSets but realurl is very hard to understand and I don’t have the technical skills to deal with it:

<?php

'postVarSets' => [
    66 => array(
        array(
            'GETvar' => 'car_brand',
            'valueMap' => array(
                'no-comments' => 1
            ),
        

    'noMatch' => 'bypass',
        )
    ),

    ...

]

2

Answers


  1. May be you can try something like this :

    'postVarSets' => array(
        '66' => array(
            'brand' => array(
                array(
                    'GETvar' => 'car_brand',
                    'noMatch' => 'bypass',
                ),
            ),
        ),
    ),
    

    So the URL will look like this

    https://www.mywebsite.com/cars/brand/audi

    May be there is also a solution with fixedPostVars to avoid the ‘brand’ segment but in that case, the get parameter ‘?car_brand=xxx’ must be always set so I think it not possible to have only : https://www.mywebsite.com/cars

    Or another solution could be to use a userFunc, then you can manage yourself the URL encoding/decoding.

    Florian

    Login or Signup to reply.
  2. To add a userFunc, have a look there :

    https://github.com/dmitryd/typo3-realurl/wiki/Configuration-reference#userfunc

    In realurl_conf.php :

    'postVarSets' => array(
        '66' => array(
            'brand' => array(
                array(
                    'GETvar' => 'car_brand',
                    'userFunc' => 'VendorUserfuncsExample->myExampleFunction',
                    'noMatch' => 'bypass',
                ),
            ),
        ),
    ),
    

    In your class :

    namespace VendorUserfuncs;
    class Example {
        function myExampleFunction($params, $ref) {
            if ($params["decodeAlias"]) {
                return ($decodedAlias));
            } else {
                return ($encodedAlias));
            }
        }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search