This question depends on your needs. There are several ways to solve this.
1: You want a redirect:
A) realURL Redirects in the Info modul:
There is a way to write redirect rules for exact urls inside the TYPO3 backend. It could be handy if an editor should have some freedom to set those rules.
Advantage:
An editor can have the opportunity to set the urls. You don't need any programming for that.
Disadvantage:
You have no regex, you need to set each urls directly. IF you change a title, the redirect won't work anymore.
Go in the Info modul and select in the head line the "RealURL Management" and after by the Show the "Redirects" option.
B) Using encodeSpURL_postProc
and decodeSpURL_preProc
in RealURLConfiguration.php.
With this technic you can manipulate your "incoming" and "outgoing" urls. It is used if you want to shorten urls.
Here is an example, but for sure you can find more in google.
Advantage:
You can make flexible regex rules.
Disadvantage:
You need to write PHP code, and this logic will run by each outgoing links, so if you have a lot of links to transform it is may not the quickest option to pick.
C) You write two lines into your .htaccess.
So the point is, that if you have a clear rule to rewrites more urls and permanently. And if you have access to your .htaccess file then I strongly recommend you to use it. If you don't have more hundred or tausend specific redirects it is the best place to write your rule. It runs before any PHP code so it is definitely the quickest solution.
Advantage:
You don't need to write as many code. It is the best way to redirect multiple urls and the performance is higher then any php code.
Disadvantage:
Only if you have no access to the .htaccess file, because then you can not do it. Otherwise with to many redirects it is better to place the redirects into the httpd conf.
2: 404 for any wrong url.
You can handle the pages as they would be "wrong urls" like www.yourpage.com/it_is_a_not_existing_page/. It is recommended to have a 404 page to handle those problems.
In this case if you copy the parts from your website into the startpage you can set the pages to hidden, and then they will throw a 404 error just like a true invalid request.
I recommend you to think about the 404 solution and if not then use .htaccess.