Score:0

Nginx location block for wordpress and legacy files

us flag

I am trying to serve legacy html website documents from the new site which is a wordpress site.

The new site is using nginx and I want to be able to serve files which are structured with a permalink like /articles/file-uri and the 10 years of legacy html static files from a directory in the root called legacy.

So, again, I want to try incoming request files against wordpress root and if the requested file is not found, search the legacy files for a static html article.. This works but it will not go back to legacy for the image files, javascript, etc ..

The location block below will serve a legacy page but not the images and javascript etc inside ... Any help would be very much appreciated. Thank you.

I have had some success with these blocks :

server_name myserver.com www.myserver.com;
access_log /var/log/nginx/myserver.com.access.log rt_cache_redis;
error_log /var/log/nginx/myserver.com.error.log;

root /var/www/myserver.com/htdocs;
index index.php;

location ^~ .php$ {
tryfiles $uri =404;
include fastcgiparams;
fastcgi_pass php74;
}

location / {
try_files $uri $uri/ /legacy$uri /legacy$uri/ /index.php$args;
}

include common/redis-php74.conf;
include common/wpcommon-php74.conf;
include common/locations-wo.conf;
Michael Hampton avatar
cz flag
WordPress generates its own errors so you will need to try legacy documents first, not last.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.