Showing results for 
Search instead for 
Did you mean: 

Magento2 Ngix static files at subdirectory

Magento2 Ngix static files at subdirectory

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:

this product now is deleted but his static page is under


I use nginx server with standard "sample" configuration. How I must modify configuration to serve this pages?

Thank U for help in advance


Re: Magento2 Ngix static files at subdirectory

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 ``, 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.