I'm trying to remove certain characters from old URLs upon redirecting to a new URL.
The characters are:
! * _
I have an old website:
old.com/forums
and a new website:
new.com/community
I'd like to redirect many URLs, some which look like this:
old.com/forums/thread/68.baking!muffins!_yummy*
old.com/forums/thread/419.hellothere
I want them to look like this:
new.com/community/thread/68.bakingmuffinsyummy
new.com/community/thread/419.hellothere
Here's my failed attempt at a directive to remove the ! character:
rewrite ^/forums(.*)[!](.*)$ new.com/community$1$2 permanent;
It only removes the last !, and doesn't work if there isn't a ! present. What am I doing wrong? Is this even possible with regex?