diff --git a/_deploy/nginx/default.conf b/_deploy/nginx/default.conf index 6725509078..bf3a6290f8 100644 --- a/_deploy/nginx/default.conf +++ b/_deploy/nginx/default.conf @@ -9,4 +9,18 @@ server { # Enable aio for better performance (see https://www.nginx.com/blog/thread-pools-boost-performance-9x/) aio threads; + + location ~ ^/v([\d\.]+)/(.*)$ { + # Archive URLs: first try if the given file is still hosted, otherwise + # redirect to the same URL in the current version of the docs. + try_files $uri $uri/ @redirect_current; + } + + location @redirect_current { + # Do a 301 (moved permanently) redirect of archive pages we didn't find + # to the same location in the current docs. Note that the location redirected + # to may not (or no longer) exist, and as such could result in another 301 + # redirect, or a 404. + rewrite ^/v([\d\.]+)/(.*)$ /$2 permanent; + } }