Netresearch Blog

Blog

Our blog contains all news and insights. We make our knowledge available, give tips, and inform you about everything that happens inside and outside 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

New Blogposts

Continous Testing: Molecule und Vagrant

By Sebastian Mendel genannt Mendelsohn

How Ansible, Molecule and Vagrant are revolutionizing testing

Make Ansible automations testable and detect deployment errors earlier? Discover how to automate…

Read more
Netresearch: TYPO3 Developer Days Karlsruhe 2022
By Tobias Hein
August 4-7, 2022: TYPO3 Developer Days in Karlsruhe

Netresearch war dieses Jahr mit zwei Pro-Sessions bei den TYPO3 Developer Days in Karlsruhe…

Read more
20 years of AIDA customer relationship
By Caroline Kindervater
We celebrate 20 years cooperation with AIDA

Communication, expertise and trust play a major role in the successful implementation of customer…

Read more
Livegang SSO-Anbindung with Keycloak for Lehrerwelt
By Thomas Schöne
SSO connection with Keycloak for TYPO3 and Magento

For our customer AAP Lehrerwelt GmbH, which is part of the Klett Group, we implemented a…

Read more