Netresearch Blog

Blog

You can find all the news and insights here. We share our knowledge, give tips and inform you about everything that happens internally and externally at our company.

The TYPO3 Redirects module: Technical documentation with source code

New tool in the backend since TYPO3 9: Redirects

Since TYPO3 v9 there is a new standard module in the backend under the new item page management: Redirects. There is currently little or no technical documentation available, although this tool has many advantages in everyday work. Above all, it allows backend users (e.g. editors, SEO managers, content managers) to easily create URL redirects.

Necessity of a redirect module

In the past, redirects have been inserted directly into the source code, or a custom implementation has been used. This is particularly problematic when a server change takes place (e.g. from Apache to nginx), since the syntax has to be adapted according to the server. Before TYPO3 offered redirects, it was the developer's task to set up URL redirects. With the new module, editors of a TYPO3 website can do this themselves.

Function and advantages of the redirect module

The Redirects module works with fields like source and target URL as well as other features like GET parameters and the HTTP header status.

  1. First the source domain is entered. If there are several domains, a drop-down can be used to make the appropriate assignment.
  2. a. If there is a path to the domain that should be redirected, this is entered in the next field (Source Path).
    b. If an entire page and its sub-pages are to be redirected to a new domain, the code /.*/ (slash-dot-star-slash) must be entered in this field. The forwarding takes effect for all pages and subpages of the website.
    IMPORTANT: The names of the paths (e.g. in the navigation: homepage, about us, imprint, etc.) in the target URL must be identical to the source URL.
    c. Paths with placeholders only work when Is regular expression? is enabled.
  3. Respect GET Parameters means that the parameters after the URL are also taken into account (e.g. for forms).
  4. Target defines the destination URL.
  5. The Status Code HTTP Header describes if the forwarding should be temporary or permanent. For temporary forwardings, the old domain is still indexed.
  6. If the site has an SSL certificate (HTTPS), the option Force SSL Redirect supports this. Otherwise it can remain deactivated.
  7. To retain the parameters after the source URL in the target URL, select Keep GET Parameters.
  8. For mass forwarding of URLs from an old section to a new one, or after a section has been renamed, regular expressions can also be used in the source URL. For this purpose the option Is regular expression? must be enabled.

Although the syntax needs to be cleaned up to get the module to work when switching from version 8 (or lower) to 9, there are several advantages:

  Saves time: No code needed for redirects
  Easy to use: No developer needed
  Webserver-independent: Configuration of the webserver stays clean
  Clear overview: Central location for redirect configuration
  Automatic redirections: When renaming a page, the old path is automatically redirected to the new one
  Webserver performance not important: Smart caching mechanism executes redirects before initializing TYPO3

Source code examples

NGINX & Apache

# Weiterleitung aller anfragen von einer Domain zur anderen in NGINX und APACHE

# Beispiel NGINX
server {
    listen 80;

    server_name www.example.com;

    return 301 https://example.com/$request_uri;
}

# Beispiel Apache
<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com    

    RewriteEngine on
    RewriteCond %{HTTP_HOST} (^|\.)www\.example\.com$
    RewriteRule ^ https://example.com/ [L,R=301]

    ....... # Weitere Konfiguration

</VirtualHost> 

Redirects after configuration in TYPO3

$ curl -I www.example.com/impressum/
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Wed, 17 Feb 2021 07:05:04 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Redirect-By: TYPO3 Redirect 1
location: https://example.com/impressum/
X-TYPO3-Parsetime: 0ms

$ curl -I www.example.com/
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Wed, 17 Feb 2021 07:05:21 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Redirect-By: TYPO3 Redirect 1
location: https://example.com/
X-TYPO3-Parsetime: 0ms

$ curl -I www.example.com/path/to/page/
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Wed, 17 Feb 2021 07:35:14 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Redirect-By: TYPO3 Redirect 1
location: https://example.com/path/to/page/
X-TYPO3-Parsetime: 0ms

The redirects module is just right for your website? Then switch to TYPO3 v10 with us now and benefit from this new standard feature!

Teaser Redirects module TYPO3
Share article:
Related topics
TYPO3

Latest posts

Two business professionals shake hands in front of a digital world map – symbolizing a partnership in AI sales and digitalization

By Thomas Fleck

Netresearch is a new partner of the Smart Systems Hub

Netresearch is now a partner of the Smart Systems Hub - for more innovation in B2B commerce, AI and…

Read more
Man holding a smartphone, with the text 'Automated Translations in TYPO3' in the foreground, surrounded by floating country flags
By Thomas Schöne

With the TYPO3 extension autotranslate, content is translated automatically and in real time -…

Read more
Header image for the Netresearch blog article: Orange background with the text "Public Interest Technology: TYPO3 now officially recognized as a Digital Public Good." On the right side, a graphic depiction of a stylized globe surrounded by interconnected people – symbolizing global, public good–oriented digitalization.
By Franka Hesse

The Digital Public Goods Alliance has officially recognised TYPO3 as a digital public good. We…

Read more
Netresearch blog article image: “Digitalisation and AI for SMEs – Netresearch joins the Saxony Business Association” – blurred background with two business hands in handshake (suits), featuring a photo of Thomas Fleck, CEO & VP of Sales at Netresearch.
By Thomas Fleck

The future is created where people are empowered and connected. With our commitment to the Saxony…

Read more