Use Routing to rewrite URLs

This section will show you how you can rewrite the URLs for tt_address using Routing Enhancers and Aspects. TYPO3 Explained has a chapter Introduction to routing that you can read if you are not familiar with the concept yet. You will no longer need third party extensions like RealURL or CoolUri to rewrite and beautify your URLs.

How to rewrite URLs with address parameters

On setting up your page you should already have created a site configuration. You can do this in the backend module Site Managements > Sites.

Your site configuration will be stored in /config/sites/<your_identifier>/config.yaml. The following configurations have to be applied to this file.

Any URL parameters can be rewritten with the Routing Enhancers and Aspects. These are added manually in the config.yaml:

  1. Add a section routeEnhancers, if one does not already exist.
  2. Choose an unique identifier for your Routing Enhancer. It doesn’t have to match any extension key.
  3. type: For tt_address, the Extbase Plugin Enhancer (Extbase) is used.
  4. extension: the extension key, converted to UpperCamelCase.
  5. plugin: the plugin name of address is ListView, even for the detail page.
  6. After that you will configure individual routes and aspects depending on your use case.
/config/sites/<your_identifier>/config.yaml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
Address:
 type: Extbase
 limitToPages:
   - 8
   - 10
   - 11
 extension: tt_address
 plugin: ListView
 routes:
   - routePath: '/{address-title}'
     _controller: 'Address::show'
     _arguments:
       address-title: address
 aspects:
   address-title:
     type: PersistedAliasMapper
     tableName: tt_address
     routeFieldName: slug

Tip

If your routing does not work as expected, check the indentation of your configuration blocks. Proper indentation is crucial in YAML.

It is recommended to limit routeEnhancers to the pages where they are needed. This will speed up performance for building page routes of all other pages.