Hi . 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.
I have had some success with these blocks :
index index.php;
location ^~ / {
root /var/www/mysite.com/htdocs;
try_files $uri /legacy/$uri $uri/ @fallback;
}
location @fallback {
root /var/www/mysite.com/htdocs;
try_files $uri $uri/ /index.php$args;
}
However the uri http://mysite.com/ results in the index.php being forced as a download of text.
I do not see why the index.php file is being sent as application/octet-stream.
thank you for any help that you might provide.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @mji,
That’s odd.
Anyway, can you post your full Nginx configuration file so that we can see if there was anything else that could be the problem?
Additionally, do you see any errors in your Nginx Error logs?
At the top of my mind I can’t see any obvious errors or reasons as to why this is happening.
Hi and thank you –
I changed the code again … to this below … it will partially work … but will not provide the images and secondary server hits from the static html files stored in /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 …
server {
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$ { try_files $uri =404; include fastcgi_params; fastcgi_pass php74; }
location / { try_files $uri $uri/ /legacy$uri /index.php$args; }
include common/redis-php74.conf;
include common/wpcommon-php74.conf;
include common/locations-wo.conf;
}
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.