In the past there must have been an error in the generation of links all around my website.
Now I want to redirect all the malformed links that are still used by people and which lead to 404 to the correct page.
An example of a wrong url:
The correct url would be
/bar/foo, so I have to check if the url contains the name of my website: www.example.com and if it does, it should redirect to the rest
Static example: If I would write all of them individually instead of using regex
RewriteRule ^foo/bar/www.example.com/bar/foo/ /bar/foo [R=301,L]
I have spent quite some time of here reading about regex etc. but I didn't find a solution for my problem.
Thanks in advance.