I've a port URL that appears something similar to this:

http://localhost/20north/Numark/product/1/B$@!00$@!4JPPO94$@!

While redirecting this to a different URL, I have to find and take away all occurrences of "$@!" in the last area of the url, to ensure that it might be:

http://localhost/20north/Numark/product/1/B004JPPO94

Note: The final part could be anything and not simply B$@!00$@!4JPPO94$@!. Also, the positioning of $@! could be anywhere for the reason that last part.

Using mod_rewrite, you simply need this rule:

RewriteRule ^(.*)\$@!(.*)$ $1$2 [N]

Edit:

Really, there appears to become a problem once the $@! reaches the finish from the URI. Adding an additional rule to get rid of the trailing match appears to repair it:

RewriteRule ^(.*)\$@!$ $1
RewriteRule ^(.*)\$@!(.*)$ $1$2 [N]

Less than sure why which was happening.

If you are using php, you could do this the next:

<?php 
    $this_url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    if( strpos($this_url, '$@!') !== false ) 
       die(header('Location: ' . str_replace('$@!', '', $this_url))); 
?>

Edit: up-to-date the code being dynamic