0

I am looking for a rewrite that will pick up any number of defined URL's and do a return 444 on any of them. Rather than writing out each one individually, I was hoping for something where I could do like if location = defined file or list then return 444.

Example of what I am using for each URL, and this works. I would just like to replace the wp-login.php to a list of some sort.

location = /wp-login.php {
    return 444;
}

EDIT: I tried doing something like the below, but that did not work unfortunately

location = (/wp-login.php|/wp-admin.php) {
    return 444;
}

EDIT2:

Thanks Xavier Lucas, that is exactly what I needed. I used what you mentioned and then added a bit to it to add more different formatted URLs. We were getting a ton of spam to weird URL's so this worked nice.

    location ~ ^(/wp-(admin|login)\.php|/url/path(.*)|/url2(.*)) {
            return 444;
    }
Hogie
  • 3
  • 3

1 Answers1

3

Locations using regexs must use the operator ~ :

location ~ ^/wp-(admin|login)\.php$ {
    return 444;
}

Read this part of the official documentation to understand how locations work and this other part to understand what's the processing order.

Xavier Lucas
  • 13,095
  • 2
  • 44
  • 50
  • Thanks so much Xavier, that is exactly what I needed! EDIT: Formatting in a reply is strange it seems.... ill edit my first comment. – Hogie Oct 16 '14 at 15:00