I had a static files at dedicated directory under magento2 installation. This files is my html content of deleted products (for seo purposes).
For example: old url was:
https://example.com/fantastic-product
this product now is deleted but his static page is under
/my/server/magento2/deleted-products-pages/fantastic-product
I use nginx server with standard "sample" configuration. How I must modify configuration to serve this pages?
Thank U for help in advance
To serve the static HTML files located in a dedicated directory for deleted products in Magento 2 using Nginx, you can modify your Nginx configuration file by adding a new location block. Here's an example of how you can achieve this:
1. Open your Nginx configuration file for editing. It is usually located in `/etc/nginx/nginx.conf` or `/etc/nginx/conf.d/default.conf`.
2. Inside the `server` block, add a new location block to handle requests for the deleted product pages:
server {
# Your existing server configuration...
location /deleted-products-pages/ {
root /my/server/magento2;
try_files $uri $uri/ =404;
}
# Your existing server configuration...
}
Make sure to adjust the `root` directive to point to the correct path where your deleted product pages are stored.
3. Save the configuration file and exit the editor.
4. Test the Nginx configuration to ensure there are no syntax errors:
nginx -t
5. If the configuration test is successful, reload or restart Nginx to apply the changes:
systemctl reload nginx
Now, when a request is made to a URL like `https://example.com/deleted-products-pages/fantastic-product`, Nginx will serve the corresponding static HTML file located at `/my/server/magento2/deleted-products-pages/fantastic-product`.
Please note that after making changes to your Nginx configuration, it's important to test thoroughly and ensure that the static pages are being served correctly.