Search code examples
regexhttp-redirecttypo3typo3-9.x

How to redirect URLs starting with a certain path via TYPO3's redirects module?


I would like to redirect any URL that start with /oldpath/ and i assume that i will need regular expressions.

Examples:

  • /oldpath/ should be redirected.
  • /oldpath/something should be redirected.
  • something/oldpath/ should not be redirected.

I have activated "regular expressions" and tried the following inputs in "Source Path":

/oldpath/

… does not work as I would like. Everything containing /oldpath/ will be redirected, even if it is not starting with /oldpath/.

^/oldpath/(.*)$

… does nothing.

What would be the correct regular expression?


Solution

  • You need to put the regular expression for redirects between #s. So yours should be #^/oldpath/(.*)$#, though #^/oldpath/# also works.