regexperlakamai

Regex to filter email address in Urls


I need to filter out any spam requests in our url that has email address or any sort of personal information.

For example : if anyone enters the url

www.mydomain.com/en-us?email=abc@gmail.com

it should redirect to

www.mydomain.com/en-us?email=

[Use regex to pattern match the email and remove that] basically it should keep the url as is and remove emailaddress

another example

Redirect

www.mydomain.com/en-us/sompePage/SomeStructure?query=abc.gmail.com

to

www.mydomain.com/en-us/sompePage/SomeStructure?query=

This is what I tried :

(http|https)://mydomain.com/(^((?!\.)[\w-_.]*[^.])(@\w+)(\.\w+(\.\w+)?[^.\W])$ but throws an error Back story and reasoning, if interested

We looked at google analytics and realized that our website is getting with a random email address with a random query string. But Google is marking them as storing personal information and hence see it as a violation of policy. Sl we are trying to place some regex in akamai so that these requests never hit the server. (We also have a fallback javascript in place to handle the same)


Solution

  • EDIT:

    Looking more closely, I forgot we had added the Match with Regular Expressions. Our RegEx engine defaults to PCRE syntax, so you could theoretically make a comprehensive Match in the whole query string: match on regular expression

    Double check and test on the Staging platform before you commit. And double check the RegEx. I took that from emailregex.com and didn't test it myself.

    ORIGINAL:

    With Akamai, the Property Manager tool lets you do this with a new rule. You should check the documentation and test before deploying, or consult with your account team for more specific questions.

    In the rule, you'll want to add a match for the query string like so: property manager with new rule and match

    From there, add the behavior to have the Akamai platform do what you want. If it's a simple redirect, then you can use the Redirect behavior and remove the query strings completely. Something like this: redirect behavior

    As the info box says, this specific use case might be better handled with the Redirector Cloudlet. But there are many things you can do once you've matched on that query string.