Nginx RegEx to match a directory and file
- by HTF
I'm wondering if it's possible to match Wordpress directory and specific file in the same location, so at the moment I've got rule to match only the wp-admin directory:
## Restricted Access directory
location ^~ /wp-admin/ {
auth_basic "Access Denied!";
auth_basic_user_file .users;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
I would like to also match the wp-login.php file but I can't get to work, I've tried the following:
location ^~ /(wp-admin/|wp-login.php) {
...