Lars Wiegman

  • Home
  • Skills
  • Contact
  • Blog

Hold Off Spammers with Nginx

posted on February 18, 2011 #

If you run your own webserver, Nginx in my case, you can easily hide mailto links from spammers with the HTTP rewrite module.

Add the following three lines of code to your Nginx server config and replace any “mailto:user@example.com” links with “/mail/user/”.

location ~ /mail/(.*)$ {
        rewrite ^/mail/(.*)/$ mailto:$1@$host redirect;
    }

The same can be done for other schemes like for making telephone calls. Again, add the code below and replace any “tel:555-1234” links with “/call/55512345/”.

location ~ /call/(.*)$ {
        rewrite ^/call/(.*)/$ tel:$1 redirect;
    }

These are examples using Nginx but I bet the same can be accomplished with other webservers.

Read Next:

I Don't Always Test My Code

I Don’t Always Test My Code But When I Do, I Do It In Production This would make a great quote for the most interesting man in the world. Continue »

  • Home
  • Skills
  • Blog
  • Contact
  • •
  • Archive
  • Feed
  • GitHub

Copyright © 2007-2018 Lars Wiegman, lars@ at namsral.com