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


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:


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]


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:

    $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