Score:0

How to setup 410 permanently deleted on nginx

jp flag

How do I setup 410 permanently deleted on nginx for a specific URL for e.g.

https://www.example.com/product/somepage.html

Or better yet how can I do it for a specific prefix for e.g.

https://www.example.com/product/

Here I want to 410 all URLs that are /product/ for e.g. /product/page1.html, /product/page2.html etc.

Here's my current conf setup.

server {
        listen 80;
        listen [::]:80;
        server_name example.com;
        return 301 https://www.example.com$request_uri;
}


server {
        listen 80;
        listen [::]:80;
        root /var/www/example.com/html;
        index portal.php index.php  index.html index.htm;

        server_name www.example.com;

        location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
          expires 1M;
          add_header Cache-Control public;
          add_header Pragma public;
        }

        location ~ ^/\.user\.ini {
                deny all;
        }
        
        #some more config here
}
jp flag
Post it as answer so I can accept.
Score:2
jp flag

Use a return statement to generate the required status response.

A location statement with the ^~ operator is probably best as it cannot be overridden by other regular expression locations.

For example:

location ^~ /product/ { 
    return 410; 
}
I sit in a Tesla and translated this thread with Ai:

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.