Nginx + Wordpress: How do I ignore an /admin/ directory?

Posted October 3, 2016 3.9k views
NginxWordPressLEMPUbuntu 16.04

I have a standard Wordpress install on an Ubuntu 16.04 server using nginx.

Part of the DO tutorial for the Wordpress setup is to include this line:

try_files $uri $uri/ /index.php$is_args$args;

I need all requests to /admin/(.+) to avoid running through Wordpress’ index.php because the files here have nothing to do with Wordpress.

I’ve tried a standalone location /admin {…} block, if statements within location / {…} and nothing seems to work; /admin continually gets matched by the above try_files block/

Any insight as to how I need to set this up to exclude /admin and all subdirectories/files from being run through Wordpress?

Thank you!

1 comment
  • Can you share your current nginx configuration for this site? What is currently happening when you try to access files in your /admin folder?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

To follow up here. The try_files directive used in this way should only redirect things through index.php when the requested file does not exist.