Nginx config to ignore subfolders

I have WordPress installed normally, nothing fancy and all working fine there, however I have a subfolder that WordPress is performing it’s pretty-link permalinking on which is causing all manner of weird issues and returning the wrong Content-Type encoding. This is breaking the pages as they need to return their content as rss+xml.

I essentially need Nginx/Wordpress to serve anything in the /xml folder (and any under it) as is. Currently, if I visit /xml/news/index.php i get the expected result, but if I visit /xml/news the content comes back as text/html.

Can anyone help with the Nginx config for this? Current Nginx conf looks something like this:

server {
listen 80;

root /var/www/;
server_name default_server;
index index.php index.html index.htm;
charset utf-8;

location / {
try_files $uri $uri/ /index.php?$args;

location /xml {
rewrite ^ /404;
location /xml/news/ {
try_files $uri $uri/ @rewritenews;
location @rewritenews {
rewrite ^ /xml/news/index.php;

Read more here:: Nginx config to ignore subfolders

Leave a Reply

Your email address will not be published. Required fields are marked *